Class XMLDoc
- java.lang.Object
-
- org.apache.manifoldcf.core.common.XMLDoc
-
public class XMLDoc extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classXMLDoc.MyEntityResolver
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String_rcsid
-
Constructor Summary
Constructors Constructor Description XMLDoc()Creates the empty docXMLDoc(java.io.InputStream is)Build a document object tree from an input streamXMLDoc(java.lang.String data)Construct a new document tree from a string form of an xml documentXMLDoc(java.lang.StringBuilder data)Construct a new document tree from a StringBuilder form of an xml documentXMLDoc(XMLDoc oldDoc, java.lang.Object parent)Construct a document from all the children of an existing element object from another document.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDocumentElement(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.ObjectcreateElement(java.lang.Object who, java.lang.String ename)Create an elementjava.lang.ObjectcreateText(java.lang.Object who, java.lang.String data)Create a free-form data value (vs attribute value=)protected org.w3c.dom.NodeduplicateNode(org.w3c.dom.Node node)Make a (deep) copy of a node.java.util.ArrayListgetAttributes(java.lang.Object n)Extract the attribute names from the given node.java.lang.StringgetData(java.lang.Object obj)Get TEXT element value as single string.protected java.lang.ObjectgetDocument()Return the document root; may be nulljava.lang.ObjectgetElement(java.lang.Object parent, java.lang.String tagname)Return the first object to match tagnamejava.lang.StringgetNodeName(java.lang.Object el)Return element name.java.lang.ObjectgetRoot()Return root nodejava.lang.ObjectgetRoot(java.lang.Object obj)Return root nodejava.lang.StringgetValue(java.lang.Object elo, java.lang.String a)Return the value of a named attributejava.lang.StringgetXML()Serialize the document object to a safe stringjava.lang.StringgetXMLNoEntityPreamble()Get XML with no entity preamblejava.util.ArrayListprocessPath(java.lang.String path, java.lang.Object o)voidprocessPath(java.util.ArrayList returnList, java.lang.String path, java.lang.Object currentRoot)protected intsearchArrayForAttribute(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)voidsetAttribute(java.lang.Object e, java.lang.String sName, java.lang.String sValue)Set an attribute on an elementprotected voidsetDocument(java.lang.Object d)byte[]toByteArray()Convert the response for transmit
-
-
-
Field Detail
-
_rcsid
public static final java.lang.String _rcsid
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
XMLDoc
public XMLDoc() throws ManifoldCFExceptionCreates the empty doc- Throws:
ManifoldCFException
-
XMLDoc
public XMLDoc(java.lang.String data) throws ManifoldCFExceptionConstruct a new document tree from a string form of an xml document- Parameters:
data- xml to parse- Throws:
ManifoldCFException
-
XMLDoc
public XMLDoc(java.lang.StringBuilder data) throws ManifoldCFExceptionConstruct a new document tree from a StringBuilder form of an xml document- Parameters:
data- xml to parse- Throws:
ManifoldCFException
-
XMLDoc
public XMLDoc(java.io.InputStream is) throws ManifoldCFExceptionBuild 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 foundi- starting indexattribute- String to findvalue- String attribute value to match
-
getXML
public java.lang.String getXML() throws ManifoldCFExceptionSerialize the document object to a safe string- Returns:
- xml raw text
- Throws:
ManifoldCFException
-
getXMLNoEntityPreamble
public java.lang.String getXMLNoEntityPreamble() throws ManifoldCFExceptionGet XML with no entity preamble- Throws:
ManifoldCFException
-
toByteArray
public byte[] toByteArray() throws ManifoldCFExceptionConvert 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 aska- 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- Objecttagname- 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 Nodeename- 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 modifysName- String attribute namesValue- 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- Objectdata- 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.
-
-