|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.flagstone.transform.FSTransformObject
com.flagstone.transform.FSTableIndex
public class FSTableIndex
FSTableIndex is used with an FSPush action to push a reference to an entry in a table of literals onto the stack.
The value is can then be retrieved from the table and used in a subsequent calculation. The data type was extended in Flash 6 to support tables of up to 65535 strings.
In the Macromedia Flash (SWF) File Format Specification all literals used in calculations are stored as strings. When performing a series of actions each time a literal value is used in a calculation it must be pushed onto the stack. Rather than repeatedly pushing the value explicitly using an FSPush action, all the literals are added to a table in the Flash Player's memory using the FSTable action. To retrieve a literal from the table a reference to an entry in the table is pushed onto the stack using an FSTableIndex. The reduces the number of bytes required to perform a given calculation when the values are used repeatedly.
As an example consider the code required to concatenate two strings:
ArrayList actions = new ArrayList(); ... // Create the table of literals FSTable literals = new FSTable(); literals.add("abc"); literals.add("def"); actions.add(literals); ... // Create references to the string literals FSPush push = new FSPush(); push.add(new FSTableIndex(0)); push.add(new FSTableIndex(1)); actions.add(push); ... // concatenate the strings actions.add(new FSAction(FSAction.Add));
An FSTable can store up to 65536 string literals. Using a table index rather than specifying the string literal explicitly reduces considerably the number of bytes required to represent a sequence of actions.
The string literal table was introduced in Flash 5. It was extended in Flash 6 to support tables of up to 65536 strings.
Constructor Summary | |
---|---|
FSTableIndex(FSCoder coder)
Construct an FSTableIndex object, initalizing it with values decoded from an encoded object. |
|
FSTableIndex(FSTableIndex obj)
Constructs an FSTableIndex object by copying values from an existing object. |
|
FSTableIndex(int anIndex)
Constructs an FSTableIndex object referencing the value stored in the literal table. |
Method Summary | |
---|---|
void |
appendDescription(java.lang.StringBuffer buffer,
int depth)
AppendDescription is used to present a string description of the object including all nested objects up to a specified depth. |
void |
decode(FSCoder coder)
|
void |
encode(FSCoder coder)
|
boolean |
equals(java.lang.Object anObject)
Returns true if anObject is equal to this one. |
int |
getIndex()
Gets the index in the table of string literals. |
int |
length(FSCoder coder)
|
void |
setIndex(int anIndex)
Sets the index in the table of string literals. |
Methods inherited from class com.flagstone.transform.FSTransformObject |
---|
clone, name, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FSTableIndex(FSCoder coder)
coder
- an FSCoder containing the binary data.public FSTableIndex(int anIndex)
anIndex
- the index into the literal table.public FSTableIndex(FSTableIndex obj)
obj
- an FSTableIndex object.Method Detail |
---|
public int getIndex()
public void setIndex(int anIndex)
anIndex
- the index into the literal table.public boolean equals(java.lang.Object anObject)
equals
in class FSTransformObject
public void appendDescription(java.lang.StringBuffer buffer, int depth)
FSTransformObject
appendDescription
in class FSTransformObject
buffer
- a StringBuffer to which the description of each object is
appended.depth
- the maximum level of nesting up to which objects will be
displayed.public int length(FSCoder coder)
length
in class FSTransformObject
public void encode(FSCoder coder)
encode
in class FSTransformObject
public void decode(FSCoder coder)
decode
in class FSTransformObject
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |