org.apache.manifoldcf.core.common
Class XMLDoc

java.lang.Object
  extended by org.apache.manifoldcf.core.common.XMLDoc

public class XMLDoc
extends java.lang.Object


Nested Class Summary
protected static class XMLDoc.MyEntityResolver
           
 
Field Summary
static java.lang.String _rcsid
           
 
Constructor Summary
XMLDoc()
          Creates the empty doc
XMLDoc(java.io.InputStream is)
          Build a document object tree from an input stream
XMLDoc(java.lang.String data)
          Construct a new document tree from a string form of an xml document
XMLDoc(java.lang.StringBuffer data)
          Construct a new document tree from a stringbuffer form of an xml document
XMLDoc(XMLDoc oldDoc, java.lang.Object parent)
          Construct a document from all the children of an existing element object from another document.
 
Method Summary
 void addDocumentElement(java.lang.Object where, XMLDoc oldDoc, java.lang.Object parent)
          Add the children of another document's node as the children of this node.
 java.lang.Object createElement(java.lang.Object who, java.lang.String ename)
          Create an element
 java.lang.Object createText(java.lang.Object who, java.lang.String data)
          Create a free-form data value (vs attribute value=)
protected  org.w3c.dom.Node duplicateNode(org.w3c.dom.Node node)
          Make a (deep) copy of a node.
 java.util.ArrayList getAttributes(java.lang.Object n)
          Extract the attribute names from the given node.
 java.lang.String getData(java.lang.Object obj)
          Get TEXT element value as single string.
protected  java.lang.Object getDocument()
          Return the document root; may be null
 java.lang.Object getElement(java.lang.Object parent, java.lang.String tagname)
          Return the first object to match tagname
 java.lang.String getNodeName(java.lang.Object el)
          Return element name.
 java.lang.Object getRoot()
          Return root node
 java.lang.Object getRoot(java.lang.Object obj)
          Return root node
 java.lang.String getValue(java.lang.Object elo, java.lang.String a)
          Return the value of a named attribute
 java.lang.String getXML()
          Serialize the document object to a safe string
 void processPath(java.util.ArrayList returnList, java.lang.String path, java.lang.Object currentRoot)
           
 java.util.ArrayList processPath(java.lang.String path, java.lang.Object o)
           
protected  int searchArrayForAttribute(java.util.ArrayList l, int i, java.lang.String attribute, java.lang.String value)
          Having collected an arraylist from a given depth in the tree, scan the node for the current attribute specified (part of wildcard matching of xpath-like element specification)
 void setAttribute(java.lang.Object e, java.lang.String sName, java.lang.String sValue)
          Set an attribute on an element
protected  void setDocument(java.lang.Object d)
           
 byte[] toByteArray()
          Convert the response for transmit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_rcsid

public static final java.lang.String _rcsid
See Also:
Constant Field Values
Constructor Detail

XMLDoc

public XMLDoc()
       throws ManifoldCFException
Creates the empty doc

Throws:
ManifoldCFException

XMLDoc

public XMLDoc(java.lang.String data)
       throws ManifoldCFException
Construct a new document tree from a string form of an xml document

Parameters:
data - xml to parse
Throws:
ManifoldCFException

XMLDoc

public XMLDoc(java.lang.StringBuffer data)
       throws ManifoldCFException
Construct a new document tree from a stringbuffer form of an xml document

Parameters:
data - xml to parse
Throws:
ManifoldCFException

XMLDoc

public XMLDoc(java.io.InputStream is)
       throws ManifoldCFException
Build a document object tree from an input stream

Parameters:
is - InputStream of xml to parse
Throws:
ManifoldCFException

XMLDoc

public XMLDoc(XMLDoc oldDoc,
              java.lang.Object parent)
       throws ManifoldCFException
Construct a document from all the children of an existing element object from another document.

Throws:
ManifoldCFException
Method Detail

getDocument

protected java.lang.Object getDocument()
Return the document root; may be null

Returns:
document object

setDocument

protected void setDocument(java.lang.Object d)

processPath

public java.util.ArrayList processPath(java.lang.String path,
                                       java.lang.Object o)

processPath

public void processPath(java.util.ArrayList returnList,
                        java.lang.String path,
                        java.lang.Object currentRoot)

searchArrayForAttribute

protected int searchArrayForAttribute(java.util.ArrayList l,
                                      int i,
                                      java.lang.String attribute,
                                      java.lang.String value)
Having collected an arraylist from a given depth in the tree, scan the node for the current attribute specified (part of wildcard matching of xpath-like element specification)

Parameters:
l - list of elements found
i - starting index
attribute - String to find
value - String attribute value to match

getXML

public java.lang.String getXML()
                        throws ManifoldCFException
Serialize the document object to a safe string

Returns:
xml raw text
Throws:
ManifoldCFException

toByteArray

public byte[] toByteArray()
                   throws ManifoldCFException
Convert the response for transmit

Returns:
xml in byte array
Throws:
ManifoldCFException

getValue

public final java.lang.String getValue(java.lang.Object elo,
                                       java.lang.String a)
Return the value of a named attribute

Parameters:
elo - Object to ask
a - String attribute to find
Returns:
String value

getNodeName

public final java.lang.String getNodeName(java.lang.Object el)
Return element name. May return null if node not of type Element

Parameters:
el - Object to ask
Returns:
String value

getData

public final java.lang.String getData(java.lang.Object obj)
Get TEXT element value as single string.

Parameters:
obj - Element to grab data
Returns:
TXT collapsed for this element ie [tag]Julie[/tag] returns "Julie"

getRoot

public java.lang.Object getRoot()
Return root node

Returns:
untyped object for later use

getRoot

public java.lang.Object getRoot(java.lang.Object obj)
Return root node

Parameters:
obj - Object document, might not be 'this'
Returns:
untyped object for later use

getAttributes

public final java.util.ArrayList getAttributes(java.lang.Object n)
Extract the attribute names from the given node. If 'n' is not a node, no attributes will be returned but the array will not be null

Parameters:
n - Object to ask
Returns:
ArrayList of attribute names

getElement

public java.lang.Object getElement(java.lang.Object parent,
                                   java.lang.String tagname)
Return the first object to match tagname

Parameters:
parent - Object
tagname - String nodename
Returns:
null or found element (Object)

createElement

public java.lang.Object createElement(java.lang.Object who,
                                      java.lang.String ename)
Create an element

Parameters:
who - Object parent Node
ename - String element name
Returns:
Object element

addDocumentElement

public void addDocumentElement(java.lang.Object where,
                               XMLDoc oldDoc,
                               java.lang.Object parent)
Add the children of another document's node as the children of this node.


setAttribute

public void setAttribute(java.lang.Object e,
                         java.lang.String sName,
                         java.lang.String sValue)
Set an attribute on an element

Parameters:
e - Object element to modify
sName - String attribute name
sValue - String attribute value

createText

public java.lang.Object createText(java.lang.Object who,
                                   java.lang.String data)
Create a free-form data value (vs attribute value=)

Parameters:
who - Object
data - String text to add as cdata/text

duplicateNode

protected org.w3c.dom.Node duplicateNode(org.w3c.dom.Node node)
Make a (deep) copy of a node.

Parameters:
node - is the node object
Returns:
the local copy.