VASSAL.build.module
Class BasicCommandEncoder
java.lang.Object
|
+--VASSAL.build.module.BasicCommandEncoder
- All Implemented Interfaces:
- Buildable, CommandEncoder
- public class BasicCommandEncoder
- extends java.lang.Object
- implements CommandEncoder, Buildable
A CommandEncoder that handles the basic commands: AddPiece, RemovePiece, ChangePiece, MovePiece. If a module
defines custom GamePiece classes, then this class may be
overriden and imported into the module. Subclasses should override the
createDecorator(java.lang.String, VASSAL.counters.GamePiece) method or, less often, the createBasic(java.lang.String) or createPiece(java.lang.String) methods to allow instantiation
of the custom GamePiece classes.
|
Field Summary |
static java.lang.String |
ADD
|
static java.lang.String |
CHANGE
|
static java.lang.String |
MOVE
|
static java.lang.String |
REMOVE
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ADD
public static final java.lang.String ADD
REMOVE
public static final java.lang.String REMOVE
CHANGE
public static final java.lang.String CHANGE
MOVE
public static final java.lang.String MOVE
BasicCommandEncoder
public BasicCommandEncoder()
createDecorator
protected Decorator createDecorator(java.lang.String type,
GamePiece inner)
- Creates a
Decorator instance
- Parameters:
type - the type of the Decorator to be created. Once created, the
Decorator should return this value from its Decorator.myGetType() method.inner - the inner piece of the Decorator @see Decorator
createBasic
protected GamePiece createBasic(java.lang.String type)
- Create a GamePiece instance that is not a Decorator @param
type the type of the GamePiece. The created piece should
return this value from its
GamePiece.getType()
method
createPiece
protected GamePiece createPiece(java.lang.String type)
- Creates a GamePiece instance from the given type
information. Determines from the type whether the
represented piece is a
Decorator or not and
forwards to createDecorator(java.lang.String, VASSAL.counters.GamePiece) or createBasic(java.lang.String). This method should generally not need to be
overridden. Instead, override createDecorator or
createBasic
build
public void build(org.w3c.dom.Element e)
- Description copied from interface:
Buildable
- Build the object
- Specified by:
build in interface Buildable
- Following copied from interface:
VASSAL.build.Buildable
- Parameters:
e - the XML element containing the object data
addTo
public void addTo(Buildable parent)
- Description copied from interface:
Buildable
- Adds this component to its parent.
In order to make Buildable objects extensible, the child
is reponsible for adding itself to the parent. That way,
Buildable subcomponents can be defined in an extension package
without needing to modify the containing class.
- Specified by:
addTo in interface Buildable
add
public void add(Buildable b)
- Description copied from interface:
Buildable
- Adds a child component. Both this method and
Buildable.addTo(VASSAL.build.Buildable) are
invoked when adding a child to a parent
- Specified by:
add in interface Buildable
getBuildElement
public org.w3c.dom.Element getBuildElement(org.w3c.dom.Document doc)
- Specified by:
getBuildElement in interface Buildable
- Following copied from interface:
VASSAL.build.Buildable
- Returns:
- an XML element from which
this component can be built
decode
public Command decode(java.lang.String command)
- Description copied from interface:
CommandEncoder
- Translate a String into a
Command
- Specified by:
decode in interface CommandEncoder
encode
public java.lang.String encode(Command c)
- Description copied from interface:
CommandEncoder
- Translate a
Command into a String
- Specified by:
encode in interface CommandEncoder