NetKernel APIs


org.ten60.netkernel.xml.util
Class XMLUtils

java.lang.Object
  extended byorg.ten60.netkernel.xml.util.XMLUtils

public class XMLUtils
extends Object

A set of low level DOM manipulation methods


Field Summary
static String CANONICAL_BOOLEAN_FALSE
           
static String CANONICAL_BOOLEAN_TRUE
           
static String CANONICAL_NULL
           
 
Method Summary
static void appendTextedElement(Node aParent, String aName, String aValue)
          Creates a named element with text if it doesn't already exist otherwise it just sets the text below it.
static Element depthFirstTraversalNextElement(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 String escape(String aXML)
          escape the given string into a form safe to embed into an XML stream
 Document getBooleanDocument(boolean b)
           
static Element getChildElementNamed(Node aNode, String aName)
           
static Document getDocumentFor(Node aNode)
          Returns the document for a node regardless of type - why is DOM so inconsistent?
static Element getFirstChildElement(Node aNode)
          finds the first child element
static XMLUtils getInstance()
          a different instance is returned for each thread
static Element getNextSiblingElement(Node aNode)
          finds the next sibling element
 Document getNullDocument()
           
static String getPathFor(Node aNode)
           
static String getText(Node aNode)
           
static Element inOrderTraversalNext(Node aNode, Node aRoot)
          try down, then across, then ( up-across )
static Document newDocument()
          return a new empty document
static Document parse(InputStream aStream)
          parse the document in the given input stream
static Document parse(InputStream aStream, String aSystemId, EntityResolver aEntityResolver)
          parse the document in the given input stream with SystemId
static Document parse(Reader aReader)
          parse the document in the given reader
static Document parse(Reader aReader, String aSystemId, EntityResolver aEntityResolver)
          parse the document in the given reader with SystemId
static Document parseImpl(InputSource aSource, String aSystemId, EntityResolver aEntityResolver)
           
static String pleaseDOMGiveMeTheNameOf(Node aNode)
           
static Node safeDeepClone(Node aNode)
           
static void setText(Element aElement, String aText)
           
 String toXML(Node aNode, boolean aIndent, boolean aOmitDeclaration)
          serialise the given node recursively to a string
 void toXML(Writer aWriter, Node aNode, boolean aIndent, boolean aOmitDeclaration)
          write a node out recursively to the given writer
 void toXML(Writer aWriter, Node aNode, boolean aIndent, boolean aOmitDeclaration, String aEncoding, int aIndentChars)
          write a node out recursively to the given writer
static void write(Writer osw, String aName, String aValue)
          Write an XML element with text to the writer
static void writeEscaped(Writer osw, String aName, 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 String CANONICAL_NULL
See Also:
Constant Field Values

CANONICAL_BOOLEAN_TRUE

public static final String CANONICAL_BOOLEAN_TRUE
See Also:
Constant Field Values

CANONICAL_BOOLEAN_FALSE

public static final 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 Document newDocument()
return a new empty document


toXML

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

Throws:
IOException

toXML

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

Throws:
IOException

toXML

public String toXML(Node aNode,
                    boolean aIndent,
                    boolean aOmitDeclaration)
serialise the given node recursively to a string


escape

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


parse

public static Document parse(Reader aReader)
                      throws IOException,
                             SAXException
parse the document in the given reader

Throws:
IOException
SAXException

parse

public static Document parse(Reader aReader,
                             String aSystemId,
                             EntityResolver aEntityResolver)
                      throws IOException,
                             SAXException
parse the document in the given reader with SystemId

Throws:
IOException
SAXException

parse

public static Document parse(InputStream aStream)
                      throws IOException,
                             SAXException
parse the document in the given input stream

Throws:
IOException
SAXException

parse

public static Document parse(InputStream aStream,
                             String aSystemId,
                             EntityResolver aEntityResolver)
                      throws IOException,
                             SAXException
parse the document in the given input stream with SystemId

Throws:
IOException
SAXException

parseImpl

public static Document parseImpl(InputSource aSource,
                                 String aSystemId,
                                 EntityResolver aEntityResolver)
                          throws IOException,
                                 SAXException
Throws:
IOException
SAXException

getPathFor

public static String getPathFor(Node aNode)

getText

public static String getText(Node aNode)

setText

public static void setText(Element aElement,
                           String aText)

getBooleanDocument

public Document getBooleanDocument(boolean b)

getNullDocument

public Document getNullDocument()

getNextSiblingElement

public static Element getNextSiblingElement(Node aNode)
finds the next sibling element


getFirstChildElement

public static Element getFirstChildElement(Node aNode)
finds the first child element


getChildElementNamed

public static Element getChildElementNamed(Node aNode,
                                           String aName)

depthFirstTraversalNextElement

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


inOrderTraversalNext

public static Element inOrderTraversalNext(Node aNode,
                                           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 Document getDocumentFor(Node aNode)
Returns the document for a node regardless of type - why is DOM so inconsistent?


appendTextedElement

public static void appendTextedElement(Node aParent,
                                       String aName,
                                       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 Node safeDeepClone(Node aNode)

pleaseDOMGiveMeTheNameOf

public static String pleaseDOMGiveMeTheNameOf(Node aNode)

write

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

Throws:
IOException

writeEscaped

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

Throws:
IOException

NetKernel APIs


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