Package VASSAL.build.module
Class BasicCommandEncoder
java.lang.Object
VASSAL.build.module.BasicCommandEncoder
- All Implemented Interfaces:
Buildable
,CommandEncoder
- Direct Known Subclasses:
BshCommandEncoder
public class BasicCommandEncoder extends 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.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
BasicCommandEncoder.BasicPieceFactory
static interface
BasicCommandEncoder.DecoratorFactory
-
Field Summary
-
Constructor Summary
Constructors Constructor Description BasicCommandEncoder()
-
Method Summary
Modifier and Type Method Description void
add(Buildable b)
Adds a child component.void
addTo(Buildable parent)
Adds this component to its parent.void
build(Element e)
Build the objectprotected GamePiece
createBasic(String type)
Create a GamePiece instance that is not a DecoratorDecorator
createDecorator(String type, GamePiece inner)
Creates aDecorator
instanceGamePiece
createPiece(String type)
Creates a GamePiece instance from the given type information.Command
decode(String command)
Translate a String into aCommand
String
encode(Command c)
Translate aCommand
into a StringElement
getBuildElement(Document doc)
-
Field Details
-
ADD
- See Also:
- Constant Field Values
-
REMOVE
- See Also:
- Constant Field Values
-
CHANGE
- See Also:
- Constant Field Values
-
MOVE
- See Also:
- Constant Field Values
-
-
Constructor Details
-
BasicCommandEncoder
public BasicCommandEncoder()
-
-
Method Details
-
createDecorator
Creates aDecorator
instance- Parameters:
type
- the type of the Decorator to be created. Once created, the Decorator should return this value from itsDecorator.myGetType()
method.inner
- the inner piece of the Decorator- See Also:
Decorator
-
createBasic
Create a GamePiece instance that is not a Decorator- Parameters:
type
- the type of the GamePiece. The created piece should return this value from itsGamePiece.getType()
method
-
createPiece
Creates a GamePiece instance from the given type information. Determines from the type whether the represented piece is aDecorator
or not and forwards tocreateDecorator(java.lang.String, VASSAL.counters.GamePiece)
orcreateBasic(java.lang.String)
. This method should generally not need to be overridden. Instead, override createDecorator or createBasic -
build
Description copied from interface:Buildable
Build the object -
addTo
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. -
add
Description copied from interface:Buildable
Adds a child component. Both this method andBuildable.addTo(VASSAL.build.Buildable)
are invoked when adding a child to a parent -
getBuildElement
- Specified by:
getBuildElement
in interfaceBuildable
- Returns:
- an XML element from which this component can be built
-
decode
Description copied from interface:CommandEncoder
Translate a String into aCommand
- Specified by:
decode
in interfaceCommandEncoder
-
encode
Description copied from interface:CommandEncoder
Translate aCommand
into a String- Specified by:
encode
in interfaceCommandEncoder
-