NetKernel APIs


org.ten60.netkernel.xml.util
Class XMLUtils

java.lang.Object
  extended by org.ten60.netkernel.xml.util.XMLUtils

public class XMLUtils
extends java.lang.Object

A set of low level DOM manipulation methods


Field Summary
static java.lang.String CANONICAL_BOOLEAN_FALSE
           
static java.lang.String CANONICAL_BOOLEAN_TRUE
           
static java.lang.String CANONICAL_NULL
           
 
Method Summary
static void appendTextedElement(org.w3c.dom.Node aParent, java.lang.String aName, java.lang.String aValue)
          Creates a named element with text if it doesn't already exist otherwise it just sets the text below it.
static org.w3c.dom.Element depthFirstTraversalNextElement(org.w3c.dom.Node aNode)
          try down, then across, not ( up-across )
static void destroyInstance()
          removes singleton associated with the current thread
static void destroyInstances()
          clear out all singletons
static java.lang.String escape(java.lang.String aXML)
          escape the given string into a form safe to embed into an XML stream
 org.w3c.dom.Document getBooleanDocument(boolean b)
           
static org.w3c.dom.Element getChildElementNamed(org.w3c.dom.Node aNode, java.lang.String aName)
           
static org.w3c.dom.Document getDocumentFor(org.w3c.dom.Node aNode)
          Returns the document for a node regardless of type - why is DOM so inconsistent?
static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node aNode)
          finds the first child element
static XMLUtils getInstance()
          a different instance is returned for each thread
static org.w3c.dom.Element getNextSiblingElement(org.w3c.dom.Node aNode)
          finds the next sibling element
 org.w3c.dom.Document getNullDocument()
           
static java.lang.String getPathFor(org.w3c.dom.Node aNode)
           
static java.lang.String getText(org.w3c.dom.Node aNode)
           
static org.w3c.dom.Element inOrderTraversalNext(org.w3c.dom.Node aNode, org.w3c.dom.Node aRoot)
          try down, then across, then ( up-across )
static org.w3c.dom.Document newDocument()
          return a new empty document
static org.w3c.dom.Document parse(java.io.InputStream aStream)
          parse the document in the given input stream
static org.w3c.dom.Document parse(java.io.Reader aReader)
          parse the document in the given reader
static java.lang.String pleaseDOMGiveMeTheNameOf(org.w3c.dom.Node aNode)
           
static org.w3c.dom.Node safeDeepClone(org.w3c.dom.Node aNode)
           
static void setText(org.w3c.dom.Element aElement, java.lang.String aText)
           
 java.lang.String toXML(org.w3c.dom.Node aNode, boolean aIndent, boolean aOmitDeclaration)
          serialise the given node recursively to a string
 void toXML(java.io.Writer aWriter, org.w3c.dom.Node aNode, boolean aIndent, boolean aOmitDeclaration)
          write a node out recursively to the given writer
 void toXML(java.io.Writer aWriter, org.w3c.dom.Node aNode, boolean aIndent, boolean aOmitDeclaration, java.lang.String aEncoding, int aIndentChars)
          write a node out recursively to the given writer
static void write(java.io.Writer osw, java.lang.String aName, java.lang.String aValue)
          Write an XML element with text to the writer
static void writeEscaped(java.io.Writer osw, java.lang.String aName, java.lang.String aValue)
          Write an escaped XML element with text to the writer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CANONICAL_NULL

public static final java.lang.String CANONICAL_NULL
See Also:
Constant Field Values

CANONICAL_BOOLEAN_TRUE

public static final java.lang.String CANONICAL_BOOLEAN_TRUE
See Also:
Constant Field Values

CANONICAL_BOOLEAN_FALSE

public static final java.lang.String CANONICAL_BOOLEAN_FALSE
See Also:
Constant Field Values
Method Detail

getInstance

public static XMLUtils getInstance()
a different instance is returned for each thread


destroyInstances

public static void destroyInstances()
clear out all singletons


destroyInstance

public static void destroyInstance()
removes singleton associated with the current thread


newDocument

public static org.w3c.dom.Document newDocument()
return a new empty document


toXML

public void toXML(java.io.Writer aWriter,
                  org.w3c.dom.Node aNode,
                  boolean aIndent,
                  boolean aOmitDeclaration,
                  java.lang.String aEncoding,
                  int aIndentChars)
           throws java.io.IOException
write a node out recursively to the given writer

Throws:
java.io.IOException

toXML

public void toXML(java.io.Writer aWriter,
                  org.w3c.dom.Node aNode,
                  boolean aIndent,
                  boolean aOmitDeclaration)
           throws java.io.IOException
write a node out recursively to the given writer

Throws:
java.io.IOException

toXML

public java.lang.String toXML(org.w3c.dom.Node aNode,
                              boolean aIndent,
                              boolean aOmitDeclaration)
serialise the given node recursively to a string


escape

public static java.lang.String escape(java.lang.String aXML)
escape the given string into a form safe to embed into an XML stream


parse

public static org.w3c.dom.Document parse(java.io.Reader aReader)
                                  throws java.io.IOException,
                                         org.xml.sax.SAXException
parse the document in the given reader

Throws:
java.io.IOException
org.xml.sax.SAXException

parse

public static org.w3c.dom.Document parse(java.io.InputStream aStream)
                                  throws java.io.IOException,
                                         org.xml.sax.SAXException
parse the document in the given input stream

Throws:
java.io.IOException
org.xml.sax.SAXException

getPathFor

public static java.lang.String getPathFor(org.w3c.dom.Node aNode)

getText

public static java.lang.String getText(org.w3c.dom.Node aNode)

setText

public static void setText(org.w3c.dom.Element aElement,
                           java.lang.String aText)

getBooleanDocument

public org.w3c.dom.Document getBooleanDocument(boolean b)

getNullDocument

public org.w3c.dom.Document getNullDocument()

getNextSiblingElement

public static org.w3c.dom.Element getNextSiblingElement(org.w3c.dom.Node aNode)
finds the next sibling element


getFirstChildElement

public static org.w3c.dom.Element getFirstChildElement(org.w3c.dom.Node aNode)
finds the first child element


getChildElementNamed

public static org.w3c.dom.Element getChildElementNamed(org.w3c.dom.Node aNode,
                                                       java.lang.String aName)

depthFirstTraversalNextElement

public static org.w3c.dom.Element depthFirstTraversalNextElement(org.w3c.dom.Node aNode)
try down, then across, not ( up-across )


inOrderTraversalNext

public static org.w3c.dom.Element inOrderTraversalNext(org.w3c.dom.Node aNode,
                                                       org.w3c.dom.Node aRoot)
try down, then across, then ( up-across )

Parameters:
aNode - next element after this node
aRoot - we will not traverse higher than this node (if null ignored)

getDocumentFor

public static org.w3c.dom.Document getDocumentFor(org.w3c.dom.Node aNode)
Returns the document for a node regardless of type - why is DOM so inconsistent?


appendTextedElement

public static void appendTextedElement(org.w3c.dom.Node aParent,
                                       java.lang.String aName,
                                       java.lang.String aValue)
Creates a named element with text if it doesn't already exist otherwise it just sets the text below it.

Parameters:
aParent - node to add element below
aName - name of element
aValue - text value below element

safeDeepClone

public static org.w3c.dom.Node safeDeepClone(org.w3c.dom.Node aNode)

pleaseDOMGiveMeTheNameOf

public static java.lang.String pleaseDOMGiveMeTheNameOf(org.w3c.dom.Node aNode)

write

public static void write(java.io.Writer osw,
                         java.lang.String aName,
                         java.lang.String aValue)
                  throws java.io.IOException
Write an XML element with text to the writer

Throws:
java.io.IOException

writeEscaped

public static void writeEscaped(java.io.Writer osw,
                                java.lang.String aName,
                                java.lang.String aValue)
                         throws java.io.IOException
Write an escaped XML element with text to the writer

Throws:
java.io.IOException

NetKernel APIs


Copyright © 2002-2004 1060 Research Ltd. All Rights Reserved.