Package VASSAL.build
Class AbstractBuildable
java.lang.Object
VASSAL.search.AbstractImageFinder
VASSAL.build.AbstractBuildable
- All Implemented Interfaces:
Buildable
,PropertyNameSource
,ValidityChecker
,Auditable
,ImageSearchTarget
- Direct Known Subclasses:
AbstractConfigurable
,BoardPicker
,BrowserHelpFile
,ChatServerControls
,ConnectionWindow
,DebugControls
,EventLog
,MapCenterer
,ModuleExtension
,PieceMover
,Scroller
public abstract class AbstractBuildable
extends AbstractImageFinder
implements Buildable, ValidityChecker, PropertyNameSource, Auditable
Abstract implementation of the
Buildable
interface. To make a Buildable component, in other words a component
which can be read from the XML buildFile along with a set of attributes, extend this class -- or more likely
AbstractConfigurable
if the component is also to be editable/configurable in the Editor window.
You'll need to implement the methods and specify the Buildable attributes of this class, and the build process is
handled automatically.-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a Buildable object to this objectvoid
Adds all images used by this component AND any subcomponents to the collectionvoid
Build this component by getting all XML attributes of the XML element and callingsetAttribute(java.lang.String, java.lang.Object)
with the String value of the attribute<T> List
<T> getAllDescendantComponentsOf
(Class<T> target) Recursively descend the build tree and return aList
of all components that are instances of the given classabstract String[]
Lists all the buildFile (XML) attribute names for this component.abstract String
Deprecated, for removal: This API element is subject to removal in a future version.getBuildElement
(Document doc) <T> Enumeration
<T> getComponents
(Class<T> target) Deprecated, for removal: This API element is subject to removal in a future version.UsegetComponentsOf(Class)
instead.<T> List
<T> getComponentsOf
(Class<T> target) Override this method to provide a list of properties to be exposed for use by expressions in the module.void
setAncestor
(Buildable ancestor) abstract void
setAttribute
(String key, Object value) Sets a buildFile (XML) attribute value for this component.void
validate
(Buildable target, ValidationReport report) Methods inherited from class VASSAL.search.AbstractImageFinder
addLocalImageNames, getAllImageNames, getLocalImageNames
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface VASSAL.script.expression.Auditable
getComponentName, getComponentTypeName
Methods inherited from interface VASSAL.build.Buildable
addTo, isMandatory, isMovable, isUnique
-
Field Details
-
buildComponents
-
validator
-
-
Constructor Details
-
AbstractBuildable
public AbstractBuildable()
-
-
Method Details
-
getAncestor
- Returns:
- direct ancestor of this item
-
setAncestor
- Parameters:
ancestor
- Sets the direct ancestor of this item
-
getNonFolderAncestor
- Returns:
- first non-folder ancestor of this item
-
build
Build this component by getting all XML attributes of the XML element and callingsetAttribute(java.lang.String, java.lang.Object)
with the String value of the attribute -
getAttributeNames
Lists all the buildFile (XML) attribute names for this component. If this component is ALSO anAbstractConfigurable
, then this list of attributes determines the appropriate attribute order forAbstractConfigurable.getAttributeDescriptions()
andAbstractConfigurable.getAttributeTypes()
.- Returns:
- a list of all buildFile (XML) attribute names for this component
-
setAttribute
Sets a buildFile (XML) attribute value for this component. Thekey
parameter will be one of those listed ingetAttributeNames()
. If thevalue
parameter is a String, it will be the value returned bygetAttributeValueString(java.lang.String)
for the samekey
. If the implementing class extendsAbstractConfigurable
, thenvalue
will be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()
- Parameters:
key
- the name of the attribute. Will be one of those listed ingetAttributeNames()
value
- If thevalue
parameter is a String, it will be the value returned bygetAttributeValueString(java.lang.String)
for the samekey
. If the implementing class extendsAbstractConfigurable
, thenvalue
can also be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()
-
getAttributeValueString
- Parameters:
key
- the name of the attribute. Will be one of those listed ingetAttributeNames()
- Returns:
- a String representation of the XML buildFile attribute with the given name. When initializing a module,
this String value will loaded from the XML and passed to
setAttribute(java.lang.String, java.lang.Object)
. It is also frequently used for checking the current value of an attribute.
-
getComponents
@Deprecated(since="2020-08-06", forRemoval=true) public <T> Enumeration<T> getComponents(Class<T> target) Deprecated, for removal: This API element is subject to removal in a future version.UsegetComponentsOf(Class)
instead.- Returns:
- all build components that are an instance of the given class
-
getComponentsOf
-
getAllDescendantComponentsOf
-
buildString
- Returns:
- an XML element that can be used to
Buildable.build(org.w3c.dom.Element)
the object.
-
getBuildElement
- Specified by:
getBuildElement
in interfaceBuildable
- Parameters:
doc
- XML file- Returns:
- an XML element from which this component can be built
-
add
-
getBuildComponents
Deprecated, for removal: This API element is subject to removal in a future version.UsegetBuildables()
instead.- Returns:
- an enumeration of Buildable objects which are the direct children
of this object in the Buildable containment hierarchy. The
getBuildElement(org.w3c.dom.Document)
method uses these objects to construct the XML element from which this object can be built.
-
getBuildables
- Returns:
- a Collection of Buildable objects which are the direct children
of this object in the Buildable containment hierarchy. The
getBuildElement(org.w3c.dom.Document)
method uses these objects to construct the XML element from which this object can be built.
-
validate
- Specified by:
validate
in interfaceValidityChecker
-
getPropertyNames
Override this method to provide a list of properties to be exposed for use by expressions in the module.- Specified by:
getPropertyNames
in interfacePropertyNameSource
- Returns:
- Default implementation of PropertyNameSource - No properties exposed
-
addImageNamesRecursively
Adds all images used by this component AND any subcomponents to the collection- Specified by:
addImageNamesRecursively
in interfaceImageSearchTarget
- Overrides:
addImageNamesRecursively
in classAbstractImageFinder
- Parameters:
s
- Collection to add image names to
-
getBuildables()
instead.