com.bea.b2b.rosettanet.util
Class XmlProcessor

java.lang.Object
  |
  +--com.bea.b2b.rosettanet.util.XmlProcessor

public class XmlProcessor
extends java.lang.Object

This class is a helper to read and update an XML template or message. The XML template or message is represented internally as a DOM Document. The methods are invoked from the example workflows's business operations.

Author:
Copyright © 2000 BEA Systems, Inc. All Rights Reserved.

Constructor Summary
XmlProcessor()
           
 
Method Summary
 boolean exist(java.lang.String elementType)
          Check to see if a node exists in the internally stored DOM Document.
 org.w3c.dom.Document getDoc()
          Return the internal DOM Document
 java.lang.String getElementContent(java.lang.String elementType)
          Obtain the content for an element in the internally stored DOM Document.
 java.lang.String getXml()
          Method that returns the internally stored DOM Document as a String.
 org.w3c.dom.Node searchDOMNode(java.lang.String name, org.w3c.dom.Node root, long elementIndex)
          A method that searchs (recursively) the internal DOM Document for a specific element.
 void setDoc(org.w3c.dom.Document indoc)
          Assign the internal DOM Document to the one passed in
 void setElementContent(java.lang.String elementType, java.lang.String elementContent)
          Update the content for an element type in the internally stored DOM Document.
 void setXml(java.lang.String xml)
          Assign a String version of the XML document.
 void setXmlFile(java.lang.String filename)
          Assign an XML file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlProcessor

public XmlProcessor()
Method Detail

getDoc

public org.w3c.dom.Document getDoc()
Return the internal DOM Document

Returns:
internal DOM Document

setDoc

public void setDoc(org.w3c.dom.Document indoc)
Assign the internal DOM Document to the one passed in

Parameters:
indoc - a DOM Document to assign to the internal DOM Document

setXmlFile

public void setXmlFile(java.lang.String filename)
                throws java.io.IOException,
                       org.xml.sax.SAXException
Assign an XML file. The file is parsed and stored internally as a DOM Document for processing.

Parameters:
filename - name of the XML file to be parsed
Throws:
java.io.IOException - error processing the XML file
org.xml.sax.SAXException - error parsing the XML file

setXml

public void setXml(java.lang.String xml)
            throws java.io.IOException,
                   org.xml.sax.SAXException
Assign a String version of the XML document. The string is parsed and stored internally as a DOM Document for processing.

Parameters:
xml - an XML document in a String format
Throws:
java.io.IOException - error processing the XML string
org.xml.sax.SAXException - error parsing the XML file

getXml

public java.lang.String getXml()
                        throws java.io.IOException
Method that returns the internally stored DOM Document as a String.

Returns:
a String respresenting the internally stored DOM Document
Throws:
java.io.IOException - error processing the internal DOM Document

exist

public boolean exist(java.lang.String elementType)
Check to see if a node exists in the internally stored DOM Document.

Parameters:
elementType - the full path of the element in the DOM Document
Returns:
true if it exists false if it does not

getElementContent

public java.lang.String getElementContent(java.lang.String elementType)
Obtain the content for an element in the internally stored DOM Document. Be sure to check that the element exists before attempting to get the content.

Parameters:
elementType - the full path of the element in the DOM Document
Returns:
a String representing the content of the element type

setElementContent

public void setElementContent(java.lang.String elementType,
                              java.lang.String elementContent)
Update the content for an element type in the internally stored DOM Document. Be sure to verify the element exists before setting the content.

Parameters:
elementType - the full path of the element in the DOM Document
elementContent - the value for the element

searchDOMNode

public org.w3c.dom.Node searchDOMNode(java.lang.String name,
                                      org.w3c.dom.Node root,
                                      long elementIndex)
A method that searchs (recursively) the internal DOM Document for a specific element.

Parameters:
name - name of the element
root - the starting root of the current position in the DOM Document
elementIndex - the current index of the element
Returns:
the node in the DOM Document of the element