com.flagstone.transform.action
Class Table

java.lang.Object
  extended by com.flagstone.transform.action.Table
All Implemented Interfaces:
Action, Copyable<Action>, SWFEncodeable

public final class Table
extends Object
implements Action

Table is used to create a table of string literals that can be referenced by an index rather than using the literal value when executing a sequence of actions.

Variables and built-in functions are specified by their name and the Table class contains a table of the respective strings. References to a variable or function can then use its index in the table rather than the name resulting in a more compact representation when the actions are encoded into binary form.

See Also:
TableIndex, Push

Constructor Summary
Table()
          Creates an empty Table.
Table(List<String> list)
          Creates a Table using the list of strings.
Table(SWFDecoder coder)
          Creates and initialises a Table action using values encoded in the Flash binary format.
Table(Table object)
          Creates and initialises a Table action using the values copied from another Table action.
 
Method Summary
 Table add(String aString)
          Adds a String to the variable table.
 Table copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 List<String> getValues()
          Get the table of strings.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setValues(List<String> list)
          Sets the list of Strings stored in the literal table.
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Table

public Table(SWFDecoder coder)
      throws IOException
Creates and initialises a Table action using values encoded in the Flash binary format.

Parameters:
coder - an SWFDecoder object that contains the encoded Flash data.
Throws:
IOException - if an error occurs while decoding the data.

Table

public Table()
Creates an empty Table.


Table

public Table(List<String> list)
Creates a Table using the list of strings.

Parameters:
list - of Strings that will be added to the table. Must not be null.

Table

public Table(Table object)
Creates and initialises a Table action using the values copied from another Table action.

Parameters:
object - a Table action from which the values will be copied.
Method Detail

add

public Table add(String aString)
Adds a String to the variable table.

Parameters:
aString - a String that will be added to the end of the table. Must not be null.
Returns:
this table.

getValues

public List<String> getValues()
Get the table of strings.

Returns:
the list of Strings stored in the table.

setValues

public void setValues(List<String> list)
Sets the list of Strings stored in the literal table.

Parameters:
list - a list of Strings that will replaces the existing literal table. Must not be null.

copy

public Table copy()
Creates a complete copy of this object.

Specified by:
copy in interface Copyable<Action>
Returns:
a deep-copy of this object. New instances of mutable objects are copied and immutable instances are shared.

toString

public String toString()

Overrides:
toString in class Object

prepareToEncode

public int prepareToEncode(Context context)
Prepare an object for encoding, returning the expected size of an object when it is encoded. This method also used to initialise variables, such as offsets and flags that will be used when the object is encoded. Generally the method returns the size in bytes, however when called on objects that use bit fields such as shapes the methods will return the size in bits.

Specified by:
prepareToEncode in interface SWFEncodeable
Parameters:
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Returns:
the size of the object when it is encoded.

encode

public void encode(SWFEncoder coder,
                   Context context)
            throws IOException
Encode an object to the Flash binary format.

Specified by:
encode in interface SWFEncodeable
Parameters:
coder - an SWFEncoder object.
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Throws:
IOException - if an error occurs while encoding the object.


Copyright © 2002-2010 Flagstone Software Ltd.. All Rights Reserved.