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 Details

  • Constructor Details

    • AbstractBuildable

      public AbstractBuildable()
  • Method Details

    • getAncestor

      public Buildable getAncestor()
      Returns:
      direct ancestor of this item
    • setAncestor

      public void setAncestor(Buildable ancestor)
      Parameters:
      ancestor - Sets the direct ancestor of this item
    • getNonFolderAncestor

      public Buildable getNonFolderAncestor()
      Returns:
      first non-folder ancestor of this item
    • build

      public void build(Element e)
      Build this component by getting all XML attributes of the XML element and calling setAttribute(java.lang.String, java.lang.Object) with the String value of the attribute
      Specified by:
      build in interface Buildable
      Parameters:
      e - the XML element containing the object data
    • getAttributeNames

      public abstract String[] getAttributeNames()
      Lists all the buildFile (XML) attribute names for this component. If this component is ALSO an AbstractConfigurable, then this list of attributes determines the appropriate attribute order for AbstractConfigurable.getAttributeDescriptions() and AbstractConfigurable.getAttributeTypes().
      Returns:
      a list of all buildFile (XML) attribute names for this component
    • setAttribute

      public abstract void setAttribute(String key, Object value)
      Sets a buildFile (XML) attribute value for this component. The key parameter will be one of those listed in getAttributeNames(). If the value parameter is a String, it will be the value returned by getAttributeValueString(java.lang.String) for the same key. If the implementing class extends AbstractConfigurable, then value will be an instance of the corresponding Class listed in AbstractConfigurable.getAttributeTypes()
      Parameters:
      key - the name of the attribute. Will be one of those listed in getAttributeNames()
      value - If the value parameter is a String, it will be the value returned by getAttributeValueString(java.lang.String) for the same key. If the implementing class extends AbstractConfigurable, then value can also be an instance of the corresponding Class listed in AbstractConfigurable.getAttributeTypes()
    • getAttributeValueString

      public abstract String getAttributeValueString(String key)
      Parameters:
      key - the name of the attribute. Will be one of those listed in getAttributeNames()
      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.
      Returns:
      all build components that are an instance of the given class
    • getComponentsOf

      public <T> List<T> getComponentsOf(Class<T> target)
      Returns:
      all build components that are an instance of the given class
    • getAllDescendantComponentsOf

      public <T> List<T> getAllDescendantComponentsOf(Class<T> target)
      Recursively descend the build tree and return a List 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

      public Element getBuildElement(Document doc)
      Specified by:
      getBuildElement in interface Buildable
      Parameters:
      doc - XML file
      Returns:
      an XML element from which this component can be built
    • add

      public void add(Buildable b)
      Add a Buildable object to this object
      Specified by:
      add in interface Buildable
      Parameters:
      b - Child to attach to this buildable as a subcomponent
    • getBuildComponents

      @Deprecated(since="2020-08-06", forRemoval=true) public Enumeration<Buildable> getBuildComponents()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use getBuildables() 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

      public List<Buildable> 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

      public void validate(Buildable target, ValidationReport report)
      Specified by:
      validate in interface ValidityChecker
    • getPropertyNames

      public List<String> getPropertyNames()
      Override this method to provide a list of properties to be exposed for use by expressions in the module.
      Specified by:
      getPropertyNames in interface PropertyNameSource
      Returns:
      Default implementation of PropertyNameSource - No properties exposed
    • addImageNamesRecursively

      public void addImageNamesRecursively(Collection<String> s)
      Adds all images used by this component AND any subcomponents to the collection
      Specified by:
      addImageNamesRecursively in interface ImageSearchTarget
      Overrides:
      addImageNamesRecursively in class AbstractImageFinder
      Parameters:
      s - Collection to add image names to