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 interfaceBasicCommandEncoder.BasicPieceFactorystatic interfaceBasicCommandEncoder.DecoratorFactory -
Field Summary
-
Constructor Summary
Constructors Constructor Description BasicCommandEncoder() -
Method Summary
Modifier and Type Method Description voidadd(Buildable b)Adds a child component.voidaddTo(Buildable parent)Adds this component to its parent.voidbuild(Element e)Build the objectprotected GamePiececreateBasic(String type)Create a GamePiece instance that is not a DecoratorDecoratorcreateDecorator(String type, GamePiece inner)Creates aDecoratorinstanceGamePiececreatePiece(String type)Creates a GamePiece instance from the given type information.Commanddecode(String command)Translate a String into aCommandStringencode(Command c)Translate aCommandinto a StringElementgetBuildElement(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 aDecoratorinstance- 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 aDecoratoror 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:BuildableBuild the object -
addTo
Description copied from interface:BuildableAdds 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:BuildableAdds a child component. Both this method andBuildable.addTo(VASSAL.build.Buildable)are invoked when adding a child to a parent -
getBuildElement
- Specified by:
getBuildElementin interfaceBuildable- Returns:
- an XML element from which this component can be built
-
decode
Description copied from interface:CommandEncoderTranslate a String into aCommand- Specified by:
decodein interfaceCommandEncoder
-
encode
Description copied from interface:CommandEncoderTranslate aCommandinto a String- Specified by:
encodein interfaceCommandEncoder
-