diva.util.xml
Class CompositeBuilder

java.lang.Object
  extended by diva.util.xml.AbstractXmlBuilder
      extended by diva.util.xml.CompositeBuilder
All Implemented Interfaces:
XmlBuilder

public class CompositeBuilder
extends AbstractXmlBuilder

CompositeBuilder is a non-validating parser that uses other builders to parse and generate XML files from arbitrary collections of objects. (FIXME - more documentation here)

Version:
$Id: CompositeBuilder.java 38798 2005-07-08 20:00:01Z cxh $
Author:
Michael Shilman
Accepted Rating:
Red

Field Summary
private  java.util.HashMap _builders
          Store builder declarations as [tag, (class, builder)] for [class, (class, builder)] aliases.
static java.lang.String BUILDER_DECLS_TAG
          Indicates a group of builder declarations
static java.lang.String BUILDER_TAG
          Indicates a builder for a recognizer
static java.lang.String CLASS_TAG
          Indicates a recognizer class
static java.lang.String DTD_1
          The DTD for builder declarations.
static java.lang.String DTD_URL
          The URL where the DTD is stored.
static java.lang.String PUBLIC_ID
          The public identity of the RCL dtd file.
static java.lang.String TAG_TAG
          Indicates the tag of a recognizer
 
Constructor Summary
CompositeBuilder()
           
 
Method Summary
 void addBuilderDecls(java.io.Reader in)
          Add all of the builder declarations in the given XML document to the builder map.
 java.lang.Object build(XmlElement elt, java.lang.String type)
          Build an object based on the XML element by looking up the appropriate builder and calling that builder on the element.
private  void debug(java.lang.String out)
           
 XmlElement generate(java.lang.Object in)
          Build an XML element based on given object by looking up the appropriate builder based on the object's class name and calling that builder's generate method on the object.
static void main(java.lang.String[] args)
          Simple test of this class.
 
Methods inherited from class diva.util.xml.AbstractXmlBuilder
getDelegate, setDelegate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PUBLIC_ID

public static final java.lang.String PUBLIC_ID
The public identity of the RCL dtd file.

See Also:
Constant Field Values

DTD_URL

public static final java.lang.String DTD_URL
The URL where the DTD is stored.

See Also:
Constant Field Values

DTD_1

public static final java.lang.String DTD_1
The DTD for builder declarations.

See Also:
Constant Field Values

CLASS_TAG

public static final java.lang.String CLASS_TAG
Indicates a recognizer class

See Also:
Constant Field Values

TAG_TAG

public static final java.lang.String TAG_TAG
Indicates the tag of a recognizer

See Also:
Constant Field Values

BUILDER_TAG

public static final java.lang.String BUILDER_TAG
Indicates a builder for a recognizer

See Also:
Constant Field Values

BUILDER_DECLS_TAG

public static final java.lang.String BUILDER_DECLS_TAG
Indicates a group of builder declarations

See Also:
Constant Field Values

_builders

private java.util.HashMap _builders
Store builder declarations as [tag, (class, builder)] for [class, (class, builder)] aliases.

Constructor Detail

CompositeBuilder

public CompositeBuilder()
Method Detail

addBuilderDecls

public void addBuilderDecls(java.io.Reader in)
                     throws java.lang.Exception
Add all of the builder declarations in the given XML document to the builder map.

Throws:
java.lang.Exception

debug

private void debug(java.lang.String out)

build

public java.lang.Object build(XmlElement elt,
                              java.lang.String type)
                       throws java.lang.Exception
Build an object based on the XML element by looking up the appropriate builder and calling that builder on the element.

Specified by:
build in interface XmlBuilder
Specified by:
build in class AbstractXmlBuilder
Throws:
java.lang.Exception

generate

public XmlElement generate(java.lang.Object in)
                    throws java.lang.Exception
Build an XML element based on given object by looking up the appropriate builder based on the object's class name and calling that builder's generate method on the object.

Specified by:
generate in interface XmlBuilder
Overrides:
generate in class AbstractXmlBuilder
Throws:
java.lang.Exception

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Simple test of this class.

Throws:
java.lang.Exception