Package VASSAL.build

Class Builder

java.lang.Object
VASSAL.build.Builder

public class Builder extends Object
This class holds static convenience methods for building Buildable objects.
  • Method Details

    • build

      public static void build(Element e, Buildable parent)
      General building algorithm. For each sub-element of the build Element, this method creates an instance of the class (which must implement Buildable) whose name matches the XML element tag name, builds that instance with the sub-element, and adds it to the parent Buildable This algorithm calls a component's Buildable.build(org.w3c.dom.Element) method before calling its Buildable.addTo(VASSAL.build.Buildable) method
      Parameters:
      parent - the parent Buildable instance
    • create

      public static Buildable create(Element e) throws IllegalBuildException
      Create an instance of a class from an XML element and build it. The .class file for the named class may be either in the System's classpath or else within the DataArchive of the GameModule.
      Throws:
      IllegalBuildException - if something goes wrong when loading the class or creating an instance of it
    • createDocument

      public static Document createDocument(InputStream in) throws IOException
      Read an XML document from an InputStream
      Returns:
      the XML document
      Throws:
      IOException
    • createNewDocument

      public static Document createNewDocument()
      Create a new XML document
      Returns:
      the Document
    • writeDocument

      public static void writeDocument(Document doc, Writer writer) throws IOException
      Write an XML document to a Writer
      Parameters:
      doc - Document to be written
      writer - target XML Writer
      Throws:
      IOException
    • getText

      public static String getText(Element e)
      Returns:
      the decoded text contents of an Element node
    • toString

      public static String toString(Document doc)
      Returns:
      a String representation of an XML document
    • main

      public static void main(String[] args)