Package VASSAL.build
Class AbstractBuildable
java.lang.Object
VASSAL.build.AbstractBuildable
- All Implemented Interfaces:
Buildable
,PropertyNameSource
,ValidityChecker
- Direct Known Subclasses:
AbstractConfigurable
,BoardPicker
,BrowserHelpFile
,ChatServerControls
,ConnectionWindow
,EventLog
,MapCenterer
,ModuleExtension
,PieceMover
,Scroller
public abstract class AbstractBuildable extends Object implements Buildable, ValidityChecker, PropertyNameSource
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
Fields Modifier and Type Field Description protected List<Buildable>
buildComponents
protected ValidityChecker
validator
-
Constructor Summary
Constructors Constructor Description AbstractBuildable()
-
Method Summary
Modifier and Type Method Description void
add(Buildable b)
Add a Buildable object to this objectvoid
build(Element e)
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> Enumeration<T>
getAllDescendantComponents(Class<T> target)
Deprecated, for removal: This API element is subject to removal in a future version.<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[]
getAttributeNames()
Lists all the buildFile (XML) attribute names for this component.abstract String
getAttributeValueString(String key)
List<Buildable>
getBuildables()
Returns a Collection of Buildable objects which are the direct children of this object in the Buildable containment hierarchy.Enumeration<Buildable>
getBuildComponents()
Deprecated, for removal: This API element is subject to removal in a future version.UsegetBuildables()
instead.Element
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)
List<String>
getPropertyNames()
Override this method to provide a list of properties to be exposed for use by expressions in the module.abstract void
setAttribute(String key, Object value)
Sets a buildFile (XML) attribute value for this component.void
validate(Buildable target, ValidationReport report)
-
Field Details
-
buildComponents
-
validator
-
-
Constructor Details
-
AbstractBuildable
public AbstractBuildable()
-
-
Method Details
-
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 attribute with the given name. When initializing a module, this String value will be passed to
setAttribute(java.lang.String, java.lang.Object)
.
-
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
- Returns:
- all build components that are an instance of the given class
-
getAllDescendantComponents
@Deprecated(since="2020-08-06", forRemoval=true) public <T> Enumeration<T> getAllDescendantComponents(Class<T> target)Deprecated, for removal: This API element is subject to removal in a future version.UsegetAllDescendantComponentsOf(Class)
instead.Recursively descend the build tree and return an enumeration of all components that are instances of the given class- Parameters:
target
- Target class- Returns:
- Results
-
getAllDescendantComponentsOf
Recursively descend the build tree and return aList
of all components that are instances of the given class- Parameters:
target
- Target class- Returns:
List
of all components that are instances of the given class
-
getBuildElement
- Specified by:
getBuildElement
in interfaceBuildable
- Returns:
- an XML element from which this component can be built
-
add
Add a Buildable object to this object -
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. ThegetBuildElement(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. ThegetBuildElement(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
-
getAllDescendantComponentsOf(Class)
instead.