com.carbonfive.flash
Class LoopFinder

java.lang.Object
  extended by com.carbonfive.flash.LoopFinder
All Implemented Interfaces:
java.io.Serializable

public class LoopFinder
extends java.lang.Object
implements java.io.Serializable

LoopFinder detects infinite loops during translation to Action Script. Specific encoders notify the loop finder when they are recursing down an object hierarchy, and when they are coming out of that recursion. At a specific maximum depth (250), an InfiniteLoopException is thrown.

This class also keeps a buffer of the last 20 classes encoded, as well as a list of "possibles". The list of possibles is a collection of classes that appear in a specific pattern with themselves during the translation. For example, if during translation a Player object appears two encodings away from another Player object 50 times or more, it is listed as a "possible".

When an InfiniteLoopException is generated, both the buffer of recently encoded classes and the list of possibles is given to it. Both of these are output when InfiniteLoopException.getMessage() is called.

See Also:
Serialized Form

Constructor Summary
LoopFinder()
           
 
Method Summary
 void add(java.lang.Class klass)
          Notify LoopFinder that a specific class is being encoded.
 org.apache.commons.collections.SequencedHashMap getBuffer()
          Get the buffer of the last 20 classes encoded, as described in the class JavaDoc above.
 int getDepth()
          Get the current depth.
 java.util.Map getPossibles()
          Get the list of "possibles", as described in the class JavaDoc above.
 boolean isLoop()
          Indicates whether an infinite loop has been found or not.
 void stepIn()
          Descend one level of recursion.
 void stepOut()
          Ascend one level out of recursion.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoopFinder

public LoopFinder()
Method Detail

add

public void add(java.lang.Class klass)
Notify LoopFinder that a specific class is being encoded.

Parameters:
klass - The class being encoded

isLoop

public boolean isLoop()
Indicates whether an infinite loop has been found or not.

Returns:
true or false

getPossibles

public java.util.Map getPossibles()
Get the list of "possibles", as described in the class JavaDoc above.

Returns:
the list of "possibles"

getBuffer

public org.apache.commons.collections.SequencedHashMap getBuffer()
Get the buffer of the last 20 classes encoded, as described in the class JavaDoc above.

Returns:
the last 20 classes encoded

getDepth

public int getDepth()
Get the current depth.

Returns:
current depth

stepIn

public void stepIn()
Descend one level of recursion.


stepOut

public void stepOut()
Ascend one level out of recursion.