VASSAL.build
Class AbstractBuildable

java.lang.Object
  |
  +--VASSAL.build.AbstractBuildable
All Implemented Interfaces:
Buildable
Direct Known Subclasses:
AbstractConfigurable, ConnectionWindow, EventLog, MapCenterer, ModuleExtension, PieceMover, Scroller

public abstract class AbstractBuildable
extends java.lang.Object
implements Buildable

Abstract implementation of the Buildable interface To make a Buildable component, extend this class. You'll need to implement the methods and specify the Buildable attributes of this class, and the build process is handled automatically.


Field Summary
protected  java.util.Vector buildComponents
           
 
Constructor Summary
AbstractBuildable()
           
 
Method Summary
 void add(Buildable b)
          Add a Buildable object to this object
 void build(org.w3c.dom.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
abstract  java.lang.String[] getAttributeNames()
           
abstract  java.lang.String getAttributeValueString(java.lang.String key)
          Return a String representation of the attribute with the given name.
 java.util.Enumeration getBuildComponents()
          Returns an enumeration of Buildable objects which are the direct children of this object in the Buildable containment hierarchy.
 org.w3c.dom.Element getBuildElement(org.w3c.dom.Document doc)
           
 java.util.Enumeration getComponents(java.lang.Class target)
           
abstract  void setAttribute(java.lang.String key, java.lang.Object value)
          Sets an attribute value for this component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface VASSAL.build.Buildable
addTo
 

Field Detail

buildComponents

protected java.util.Vector buildComponents
Constructor Detail

AbstractBuildable

public AbstractBuildable()
Method Detail

build

public void build(org.w3c.dom.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 java.lang.String[] getAttributeNames()
Returns:
a list of all attribute names for this component

setAttribute

public abstract void setAttribute(java.lang.String key,
                                  java.lang.Object value)
Sets an 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()

getAttributeValueString

public abstract java.lang.String getAttributeValueString(java.lang.String key)
Return 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).

Parameters:
key - the name of the attribute. Will be one of those listed in getAttributeNames()

getComponents

public java.util.Enumeration getComponents(java.lang.Class target)
Returns:
all build components that are an instance of the given class

getBuildElement

public org.w3c.dom.Element getBuildElement(org.w3c.dom.Document doc)
Specified by:
getBuildElement in interface Buildable
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

getBuildComponents

public java.util.Enumeration getBuildComponents()
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.