Class RMASNode
- java.lang.Object
- 
- com.reportmill.flash.RMASNode
 
- 
 public final class RMASNode extends java.lang.ObjectRMASNode is the class used by the parser to construct a tree representation of an ActionScript file based on the parser grammar.Encoding a tree of nodes to the binary Flash file format is performed in four stages: 1. First the nodes in the tree are re-ordered. This is used to move function definitions to the start of the block they are defined in - matching the behaviour performed by the Flash authoring application and making regression testing of the code generated against the code generated by Flash much easier. 2. then the node tree is searched for string literals, identifier and function names to construct a table of strings that is added to the start of the script, References to strings can then be made by specifying an index into the table rathe than pushing the string onto the Flash Player's stack - greatly reducing the size of the code. 3. The node tree is translated into an array of action objects. This intermediate step is required to calculate the relative branches and jumps performed when implementing if..else statements and construct such as for and while loops. 4. The array of actions generated by the translation step is then encoded to the binary data format support by Flash. 
- 
- 
Field SummaryFields Modifier and Type Field Description static intAddstatic intAndstatic intASRstatic intAssignstatic intAssignAddstatic intAssignASRstatic intAssignBitAndstatic intAssignBitOrstatic intAssignBitXOrstatic intAssignDivstatic intAssignLSLstatic intAssignLSRstatic intAssignModstatic intAssignMulstatic intAssignSubstatic intAttributestatic intBitAndstatic intBitNotstatic intBitOrstatic intBitXOrstatic intBreakstatic intButtonstatic java.util.HashMapbuttonEventsstatic java.util.HashMapclipEventsstatic intContinuestatic intDefineArraystatic intDefineAttributestatic intDefineFunctionstatic intDefineMethodstatic intDefineObjectstatic intDefineVariablestatic intDivstatic intDostatic intEqualstatic intForstatic intForInstatic intFramestatic intFunctionstatic intGreaterThanstatic intGreaterThanEqualstatic intIdentifierstatic intIfstatic intLessThanstatic intLessThanEqualstatic intListstatic intLiteralstatic intLSLstatic intLSRstatic intMethodstatic intMinusstatic intModstatic intMovieClipstatic intMulstatic intNewObjectstatic intNoOpstatic intNotstatic intNotEqualstatic intOnstatic intOnClipEventstatic intOrstatic intPlusstatic intPostDecstatic intPostIncstatic intPreDecstatic intPreIncstatic intReturnstatic intSelectstatic intSubstatic intSubscriptstatic intValuestatic intWhilestatic intWith
 - 
Constructor SummaryConstructors Constructor Description RMASNode(int nodeType)Constructs an RMASNode with the specified type.RMASNode(int nodeType, int value)Constructs an RMASNode with the specified type and integer value.RMASNode(int nodeType, RMASNode node)Constructs an RMASNode with the specified type and adds the child node.RMASNode(int nodeType, RMASNode node1, RMASNode node2)Constructs an RMASNode with the specified type and adds the child nodes.RMASNode(int nodeType, java.lang.String value)Constructs an RMASNode with the specified type and string value.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(RMASNode aNode)Adds a node to the array of children.intcount()Return the number of child nodes contained by this node.voiddisplayTree(java.lang.String prefix)displayTree is used to display the structure of the node tree, with the root starting at the current node.byte[]encode(int version)The encode method 'compiles' the node and all child nodes into an array of action objects which represents the sequence of actions performed by the Flash Player.RMASNodeget(int index)Returns the node at the specified index from the array of child nodes.intgetIntValue()Get the integer value assigned to a node.intgetNumber()Get the number assigned to a node.RMASNodegetParent()Gets the parent node of this one.java.lang.StringgetStringValue()Get the string value assigned to a node.intgetType()Gets the type of the node.intindexOf(RMASNode aNode)Returns the index position of a node in the array of child nodes.voidinsert(int index, RMASNode aNode)Inserts a node at position i in the array of children.voidremove(int index)Removes the node at position i in the array of children.voidset(int i, RMASNode aNode)Replaces the node at position i in the array of children.voidsetIntValue(int value)Set the integer value assigned to a node.voidsetNumber(int value)Set the number assigned to a node.voidsetStringValue(java.lang.String value)Set the string value assigned to a node.voidsetType(int type)Sets the type of the node.java.lang.StringtoString()Returns a string containing the type of node, any associated value and the number of children.voidvalidate()validate is used to provide additional error checking not covered in the parser grammar.
 
- 
- 
- 
Field Detail- 
Framepublic static final int Frame - See Also:
- Constant Field Values
 
 - 
Buttonpublic static final int Button - See Also:
- Constant Field Values
 
 - 
MovieClippublic static final int MovieClip - See Also:
- Constant Field Values
 
 - 
Listpublic static final int List - See Also:
- Constant Field Values
 
 - 
NoOppublic static final int NoOp - See Also:
- Constant Field Values
 
 - 
Ifpublic static final int If - See Also:
- Constant Field Values
 
 - 
Forpublic static final int For - See Also:
- Constant Field Values
 
 - 
ForInpublic static final int ForIn - See Also:
- Constant Field Values
 
 - 
Whilepublic static final int While - See Also:
- Constant Field Values
 
 - 
Dopublic static final int Do - See Also:
- Constant Field Values
 
 - 
Withpublic static final int With - See Also:
- Constant Field Values
 
 - 
OnClipEventpublic static final int OnClipEvent - See Also:
- Constant Field Values
 
 - 
Onpublic static final int On - See Also:
- Constant Field Values
 
 - 
Breakpublic static final int Break - See Also:
- Constant Field Values
 
 - 
Returnpublic static final int Return - See Also:
- Constant Field Values
 
 - 
Continuepublic static final int Continue - See Also:
- Constant Field Values
 
 - 
Valuepublic static final int Value - See Also:
- Constant Field Values
 
 - 
Literalpublic static final int Literal - See Also:
- Constant Field Values
 
 - 
Identifierpublic static final int Identifier - See Also:
- Constant Field Values
 
 - 
Attributepublic static final int Attribute - See Also:
- Constant Field Values
 
 - 
Methodpublic static final int Method - See Also:
- Constant Field Values
 
 - 
Functionpublic static final int Function - See Also:
- Constant Field Values
 
 - 
NewObjectpublic static final int NewObject - See Also:
- Constant Field Values
 
 - 
Subscriptpublic static final int Subscript - See Also:
- Constant Field Values
 
 - 
DefineFunctionpublic static final int DefineFunction - See Also:
- Constant Field Values
 
 - 
DefineArraypublic static final int DefineArray - See Also:
- Constant Field Values
 
 - 
DefineObjectpublic static final int DefineObject - See Also:
- Constant Field Values
 
 - 
DefineMethodpublic static final int DefineMethod - See Also:
- Constant Field Values
 
 - 
DefineAttributepublic static final int DefineAttribute - See Also:
- Constant Field Values
 
 - 
DefineVariablepublic static final int DefineVariable - See Also:
- Constant Field Values
 
 - 
Addpublic static final int Add - See Also:
- Constant Field Values
 
 - 
Subpublic static final int Sub - See Also:
- Constant Field Values
 
 - 
Mulpublic static final int Mul - See Also:
- Constant Field Values
 
 - 
Divpublic static final int Div - See Also:
- Constant Field Values
 
 - 
Modpublic static final int Mod - See Also:
- Constant Field Values
 
 - 
LSLpublic static final int LSL - See Also:
- Constant Field Values
 
 - 
ASRpublic static final int ASR - See Also:
- Constant Field Values
 
 - 
LSRpublic static final int LSR - See Also:
- Constant Field Values
 
 - 
BitAndpublic static final int BitAnd - See Also:
- Constant Field Values
 
 - 
BitOrpublic static final int BitOr - See Also:
- Constant Field Values
 
 - 
BitXOrpublic static final int BitXOr - See Also:
- Constant Field Values
 
 - 
Andpublic static final int And - See Also:
- Constant Field Values
 
 - 
Orpublic static final int Or - See Also:
- Constant Field Values
 
 - 
Equalpublic static final int Equal - See Also:
- Constant Field Values
 
 - 
NotEqualpublic static final int NotEqual - See Also:
- Constant Field Values
 
 - 
GreaterThanpublic static final int GreaterThan - See Also:
- Constant Field Values
 
 - 
LessThanpublic static final int LessThan - See Also:
- Constant Field Values
 
 - 
GreaterThanEqualpublic static final int GreaterThanEqual - See Also:
- Constant Field Values
 
 - 
LessThanEqualpublic static final int LessThanEqual - See Also:
- Constant Field Values
 
 - 
Selectpublic static final int Select - See Also:
- Constant Field Values
 
 - 
Notpublic static final int Not - See Also:
- Constant Field Values
 
 - 
BitNotpublic static final int BitNot - See Also:
- Constant Field Values
 
 - 
Pluspublic static final int Plus - See Also:
- Constant Field Values
 
 - 
Minuspublic static final int Minus - See Also:
- Constant Field Values
 
 - 
PreIncpublic static final int PreInc - See Also:
- Constant Field Values
 
 - 
PreDecpublic static final int PreDec - See Also:
- Constant Field Values
 
 - 
PostIncpublic static final int PostInc - See Also:
- Constant Field Values
 
 - 
PostDecpublic static final int PostDec - See Also:
- Constant Field Values
 
 - 
Assignpublic static final int Assign - See Also:
- Constant Field Values
 
 - 
AssignAddpublic static final int AssignAdd - See Also:
- Constant Field Values
 
 - 
AssignSubpublic static final int AssignSub - See Also:
- Constant Field Values
 
 - 
AssignMulpublic static final int AssignMul - See Also:
- Constant Field Values
 
 - 
AssignDivpublic static final int AssignDiv - See Also:
- Constant Field Values
 
 - 
AssignModpublic static final int AssignMod - See Also:
- Constant Field Values
 
 - 
AssignLSLpublic static final int AssignLSL - See Also:
- Constant Field Values
 
 - 
AssignASRpublic static final int AssignASR - See Also:
- Constant Field Values
 
 - 
AssignLSRpublic static final int AssignLSR - See Also:
- Constant Field Values
 
 - 
AssignBitAndpublic static final int AssignBitAnd - See Also:
- Constant Field Values
 
 - 
AssignBitOrpublic static final int AssignBitOr - See Also:
- Constant Field Values
 
 - 
AssignBitXOrpublic static final int AssignBitXOr - See Also:
- Constant Field Values
 
 - 
buttonEventspublic static java.util.HashMap buttonEvents 
 - 
clipEventspublic static java.util.HashMap clipEvents 
 
- 
 - 
Constructor Detail- 
RMASNodepublic RMASNode(int nodeType) Constructs an RMASNode with the specified type.- Parameters:
- nodeType- the type of node being constructed.
 
 - 
RMASNodepublic RMASNode(int nodeType, int value)Constructs an RMASNode with the specified type and integer value. This constructor is primarily used to create nodes representing integer literals.- Parameters:
- nodeType- the type of node being constructed.
- value- the integer value assigned to the node.
 
 - 
RMASNodepublic RMASNode(int nodeType, java.lang.String value)Constructs an RMASNode with the specified type and string value. This constructor is primarily used to create string literals and identifiers.- Parameters:
- nodeType- the type of node being constructed.
- value- the string assigned to the node.
 
 - 
RMASNodepublic RMASNode(int nodeType, RMASNode node)Constructs an RMASNode with the specified type and adds the child node.- Parameters:
- nodeType- the type of node being constructed.
- node- a child node which will be added to the new node.
 
 - 
RMASNodepublic RMASNode(int nodeType, RMASNode node1, RMASNode node2)Constructs an RMASNode with the specified type and adds the child nodes.- Parameters:
- nodeType- the type of node being constructed.
- node1- a child node which will be added to the new node.
- node2- a child node which will be added to the new node.
 
 
- 
 - 
Method Detail- 
getTypepublic int getType() Gets the type of the node.- Returns:
- the type assigned to the node.
 
 - 
setTypepublic void setType(int type) Sets the type of the node.- Parameters:
- type- the type assigned to the node.
 
 - 
getIntValuepublic int getIntValue() Get the integer value assigned to a node.- Returns:
- the integer value assigned to a node.
 
 - 
setIntValuepublic void setIntValue(int value) Set the integer value assigned to a node.- Parameters:
- value- a value that will be assigned to the node.
 
 - 
getStringValuepublic java.lang.String getStringValue() Get the string value assigned to a node.- Returns:
- the string value assigned to a node.
 
 - 
setNumberpublic void setNumber(int value) Set the number assigned to a node.- Parameters:
- value- a unique number that will be assigned to the node.
 
 - 
getNumberpublic int getNumber() Get the number assigned to a node.- Returns:
- the number assigned to a node.
 
 - 
setStringValuepublic void setStringValue(java.lang.String value) Set the string value assigned to a node.- Parameters:
- value- a string that will be assigned to the node.
 
 - 
getpublic RMASNode get(int index) Returns the node at the specified index from the array of child nodes. If the index is outside the range of the array then an ArrayIndexOutOfBounds exception is thrown.- Parameters:
- index- the index of the child node to return.
- Returns:
- the ith node in the array of children.
- Throws:
- java.lang.ArrayIndexOutOfBoundsException- if (index < 0 || index >= length).
 
 - 
setpublic void set(int i, RMASNode aNode)Replaces the node at position i in the array of children. If the position is outside the range of the array (i< 0 || i >= length) then an ArrayIndexOutOfBoundsException is thrown.- Parameters:
- i- the index of the child node to replace.
- aNode- the node to replace the ith node.
- Throws:
- java.lang.ArrayIndexOutOfBoundsException- if (index < 0 || index >= length).
 
 - 
addpublic void add(RMASNode aNode) Adds a node to the array of children. If the node is null then it is ignored.- Parameters:
- aNode- the node to be added.
 
 - 
insertpublic void insert(int index, RMASNode aNode)Inserts a node at position i in the array of children. The size of the array is increased by one and the nodes from the insertion point onwards are moved to the right.If the position is outside the range of the array (i< 0 || i >= length) then an ArrayIndexOutOfBoundsException is thrown. - Parameters:
- index- the index of the child node to replace.
- aNode- the node to replace the ith node.
- Throws:
- java.lang.ArrayIndexOutOfBoundsException- if (index < 0 || index >= length).
 
 - 
removepublic void remove(int index) Removes the node at position i in the array of children. The size of the array is decreased by one and the nodes from the insertion point onwards are moved to the left.If the position is outside the range of the array (i< 0 || i >= length) then an ArrayIndexOutOfBoundsException is thrown. - Parameters:
- index- the index of the child node to remove.
- Throws:
- java.lang.ArrayIndexOutOfBoundsException- if (index < 0 || index >= length).
 
 - 
indexOfpublic int indexOf(RMASNode aNode) Returns the index position of a node in the array of child nodes. If the node is not one of the current nodes children then -1 is returned.- Parameters:
- aNode- the node to search the array of children for.
- Returns:
- the index of the node in the array of children, -1 if the node is not a child of this node.
 
 - 
getParentpublic RMASNode getParent() Gets the parent node of this one. If no parent is define then null is returned.- Returns:
- the parent node of this one.
 
 - 
countpublic int count() Return the number of child nodes contained by this node.- Returns:
- the number of child nodes.
 
 - 
toStringpublic java.lang.String toString() Returns a string containing the type of node, any associated value and the number of children.- Overrides:
- toStringin class- java.lang.Object
- Returns:
- the string representation of the node.
 
 - 
displayTreepublic void displayTree(java.lang.String prefix) displayTree is used to display the structure of the node tree, with the root starting at the current node. The prefix argument is used to ident the text displayed. The level of indent is increased by appending the string " " before calling the displayTree method on each child node. This illustrates the tree structure with nodes at the same level in the tree displayed with the same level of indent.- Parameters:
- prefix- the string prepended to the text representation for this node.
 
 - 
encodepublic byte[] encode(int version) The encode method 'compiles' the node and all child nodes into an array of action objects which represents the sequence of actions performed by the Flash Player. The actions are then encoded to generate the binary data that can be added to an encoded Flash file.The version of Flash for which the actions are generated is specified to ensure compatibility with future release of Flash. IMPORTANT: The programming model changed with Flash version 5 to support stack-based actions. Earlier versions of Flash are not support. An IllegalArgumentexception will be thrown if the version is earlier than 5. - Parameters:
- version- the version of Flash that control the actions that are generated.
- version- the version of Flash that the script should be encoded for.
- Returns:
- an array of bytes containing encoded action objects.
- Throws:
- IllegalArgumentexception- is the version is less than 5.
 
 - 
validatepublic void validate() throws ParseExceptionvalidate is used to provide additional error checking not covered in the parser grammar.- Throws:
- ParseException
 
 
- 
 
-