oracle.clex.util
Class XMLGeneratorBase

java.lang.Object
  |
  +--oracle.clex.util.XMLGeneratorBase
Direct Known Subclasses:
XMLGenerator

public class XMLGeneratorBase
extends java.lang.Object

Generates an xml document object for a given Values. If the Values contains another Values, the contained Values will be transformed into child elements. i.e. if an Agent has a reference to a Person, the result will be:

 
   <agent>
     <department>agent's Department</department>
     <person>
       <lastName>Doe</lastName>
       <firstName>John</firstName>
     </person>
   </agent>
 
 

Usage:
XMLGeneratorBase xg = new XMLGeneratorBase ("rootName", Values)
org.w3c.dom.Document = xg.generate();

At this time, it does not valid against a DTD, though this might be something that we may need to do in the future


Field Summary
protected  org.w3c.dom.Document doc
           
protected  org.w3c.dom.Element tmpchild
           
static java.lang.String XML_VERSION
          XML Version number
 
Constructor Summary
XMLGeneratorBase()
          Default constructor
XMLGeneratorBase(java.lang.String aRootName)
          Constructor that accepts a name for the root element
XMLGeneratorBase(java.lang.String aRootName, java.lang.Boolean useJaxp)
          Constructor that accepts a name for the root element and a boolean to use jaxp-compliant code or not.
XMLGeneratorBase(java.lang.String aRootName, java.util.Hashtable anValues)
          Constructor that accepts a name for the root element and an Values object which will be transformed into XML
XMLGeneratorBase(java.lang.String aRootName, java.util.Hashtable anValues, java.lang.Boolean useJaxp)
          Constructor that accepts a name for the root element and an Values object which will be transformed into XML and a boolean to use jaxp-compliant code or not.
XMLGeneratorBase(java.lang.String aRootName, java.util.Vector anValues, java.lang.String childname)
          Constructor that accepts a name for the root element and child element and an Values object which will be transformed into XML
XMLGeneratorBase(java.lang.String aRootName, java.util.Vector anValues, java.lang.String childname, java.lang.Boolean useJaxp)
          Constructor that accepts a name for the root element and child element and an Values object which will be transformed into XML and a boolean to use jaxp-compliant code or not.
 
Method Summary
protected  void addChild(org.w3c.dom.Element parent, java.lang.String childElementName, java.lang.Object childValue)
          Transforms the child element and adds it to the parent node
protected  void buildNodeForValues(org.w3c.dom.Element parent)
          Builds a node for the Values that is set
protected  void buildNodeForValues(org.w3c.dom.Element parent, java.util.Hashtable anValues)
          Builds a node for the given Values
protected  void buildNodeForValues(org.w3c.dom.Element parent, java.lang.Object anValues)
          Builds a node for the given Values
protected  void buildNodeForValues(org.w3c.dom.Element parent, java.util.Vector anValues)
          Builds a node for the given Values
protected  void createDocument()
          Creates the Document
 org.w3c.dom.Document generate()
          Returns the Document (XMLDocument) that is generated from the Values.
 java.lang.String getChildname()
           
 java.lang.String getRootName()
          Returns the name to be use for the root element
 java.lang.Object getValues()
           
 void setChildname(java.lang.String newChildname)
           
 void setRootName(java.lang.String aRootName)
          Sets the name to be used for the root element
 void setValues(java.lang.Object newValues)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XML_VERSION

public static final java.lang.String XML_VERSION
XML Version number

doc

protected org.w3c.dom.Document doc

tmpchild

protected org.w3c.dom.Element tmpchild
Constructor Detail

XMLGeneratorBase

public XMLGeneratorBase()
Default constructor

XMLGeneratorBase

public XMLGeneratorBase(java.lang.String aRootName,
                        java.util.Hashtable anValues)
Constructor that accepts a name for the root element and an Values object which will be transformed into XML
Parameters:
java.lang.String - Name to be used for the root element
Hashtable - The Values to be transformed

XMLGeneratorBase

public XMLGeneratorBase(java.lang.String aRootName,
                        java.util.Hashtable anValues,
                        java.lang.Boolean useJaxp)
Constructor that accepts a name for the root element and an Values object which will be transformed into XML and a boolean to use jaxp-compliant code or not.
Parameters:
java.lang.String - Name to be used for the root element
Hashtable - The Values to be transformed

XMLGeneratorBase

public XMLGeneratorBase(java.lang.String aRootName,
                        java.util.Vector anValues,
                        java.lang.String childname)
Constructor that accepts a name for the root element and child element and an Values object which will be transformed into XML
Parameters:
java.lang.String - Name to be used for the root element
Vector - The Values to be transformed
String - The child name

XMLGeneratorBase

public XMLGeneratorBase(java.lang.String aRootName,
                        java.util.Vector anValues,
                        java.lang.String childname,
                        java.lang.Boolean useJaxp)
Constructor that accepts a name for the root element and child element and an Values object which will be transformed into XML and a boolean to use jaxp-compliant code or not.
Parameters:
java.lang.String - Name to be used for the root element
Vector - The Values to be transformed
String - The child name

XMLGeneratorBase

public XMLGeneratorBase(java.lang.String aRootName)
Constructor that accepts a name for the root element
Parameters:
java.lang.String - Name to be used for the root element

XMLGeneratorBase

public XMLGeneratorBase(java.lang.String aRootName,
                        java.lang.Boolean useJaxp)
Constructor that accepts a name for the root element and a boolean to use jaxp-compliant code or not.
Parameters:
java.lang.String - Name to be used for the root element
boolean - useJaxp
Method Detail

setRootName

public void setRootName(java.lang.String aRootName)
Sets the name to be used for the root element

getRootName

public java.lang.String getRootName()
Returns the name to be use for the root element
Returns:
java.lang.String

generate

public org.w3c.dom.Document generate()
Returns the Document (XMLDocument) that is generated from the Values. Document is returned so that the result can be a generic Document, not specific to Oracle's parser. Once the Document object is retrieved, it can be cast to the specific Document implementation.
Returns:
org.w3c.dom.Document

buildNodeForValues

protected void buildNodeForValues(org.w3c.dom.Element parent)
Builds a node for the Values that is set
Parameters:
org.w3c.dom.Element - The parent node for the Values

buildNodeForValues

protected void buildNodeForValues(org.w3c.dom.Element parent,
                                  java.lang.Object anValues)
Builds a node for the given Values
Parameters:
org.w3c.dom.Element - The parent node for the Values
Object - The Values to be transformed.

buildNodeForValues

protected void buildNodeForValues(org.w3c.dom.Element parent,
                                  java.util.Hashtable anValues)
Builds a node for the given Values
Parameters:
org.w3c.dom.Element - The parent node for the Values
Hashtable - The Values to be transformed.

buildNodeForValues

protected void buildNodeForValues(org.w3c.dom.Element parent,
                                  java.util.Vector anValues)
Builds a node for the given Values
Parameters:
org.w3c.dom.Element - The parent node for the Values
Vector - The Values to be transformed.

createDocument

protected void createDocument()
                       throws java.lang.ClassNotFoundException,
                              java.lang.IllegalAccessException,
                              java.lang.InstantiationException
Creates the Document
Throws:
java.lang.ClassNotFoundException -  
java.lang.IllegalAccessException -  
java.lang.InstantiationException - Enhancement # 1575374 - Added jaxp code to retrieve a new document using the document builder rather than a hardcoded oracle doc.

addChild

protected void addChild(org.w3c.dom.Element parent,
                        java.lang.String childElementName,
                        java.lang.Object childValue)
Transforms the child element and adds it to the parent node
Parameters:
org.w3c.dom.Element - The parent Element to add a child to
java.lang.String - The name of the child element
java.lang.Object - The value of the child

getValues

public java.lang.Object getValues()

setValues

public void setValues(java.lang.Object newValues)
               throws CollectionTypeNotSupportedException

getChildname

public java.lang.String getChildname()

setChildname

public void setChildname(java.lang.String newChildname)


Copyright © 2003 ORACLE Corp. All Rights Reserved.