Package VASSAL.build
Class AbstractBuildable
java.lang.Object
VASSAL.search.AbstractImageFinder
VASSAL.build.AbstractBuildable
- All Implemented Interfaces:
Buildable,PropertyNameSource,ValidityChecker,ImageSearchTarget
- Direct Known Subclasses:
AbstractConfigurable,BoardPicker,BrowserHelpFile,ChatServerControls,ConnectionWindow,EventLog,MapCenterer,ModuleExtension,PieceMover,Scroller
public abstract class AbstractBuildable
extends AbstractImageFinder
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a Buildable object to this objectvoidAdds all images used by this component AND any subcomponents to the collectionvoidBuild 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 aListof all components that are instances of the given classabstract String[]Lists all the buildFile (XML) attribute names for this component.abstract StringDeprecated, for removal: This API element is subject to removal in a future version.UsegetBuildables()instead.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.abstract voidsetAttribute(String key, Object value)Sets a buildFile (XML) attribute value for this component.voidvalidate(Buildable target, ValidationReport report)Methods inherited from class VASSAL.search.AbstractImageFinder
addLocalImageNames, getAllImageNames, getLocalImageNames
-
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. Thekeyparameter will be one of those listed ingetAttributeNames(). If thevalueparameter is a String, it will be the value returned bygetAttributeValueString(java.lang.String)for the samekey. If the implementing class extendsAbstractConfigurable, thenvaluewill 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 thevalueparameter is a String, it will be the value returned bygetAttributeValueString(java.lang.String)for the samekey. If the implementing class extendsAbstractConfigurable, thenvaluecan 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
- 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 aListof all components that are instances of the given class- Parameters:
target- Target class- Returns:
Listof all components that are instances of the given class
-
getBuildElement
- Specified by:
getBuildElementin interfaceBuildable- Parameters:
doc- XML file- 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. 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:
validatein interfaceValidityChecker
-
getPropertyNames
Override this method to provide a list of properties to be exposed for use by expressions in the module.- Specified by:
getPropertyNamesin 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:
addImageNamesRecursivelyin interfaceImageSearchTarget- Overrides:
addImageNamesRecursivelyin classAbstractImageFinder- Parameters:
s- Collection to add image names to
-
getAllDescendantComponentsOf(Class)instead.