|
SourceJammer 1.2.0.1 May 20, 2002 Copyright (c) 2001, 2002 Robert MacGrogan |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--org.sourcejammer.xml.XMLUtil
Utility class for common functions that are performed with XML.
| Constructor Summary | |
XMLUtil()
Default constructor. |
|
| Method Summary | |
static org.w3c.dom.Element |
addNewChildElement(java.lang.String name,
org.w3c.dom.Element parent)
|
static org.w3c.dom.Element |
addNewChildElement(java.lang.String name,
java.lang.String value,
org.w3c.dom.Element parent)
Creates a new Element node with the specified name and value, and appends it to the parent Element. |
static void |
addOrReplaceElementText(org.w3c.dom.Element elm,
java.lang.String newValue)
Replace current text node with new text if exists. |
static org.w3c.dom.Element |
addRootElement(java.lang.String name,
org.w3c.dom.Document parent)
Add a root element to a document. |
static org.w3c.dom.Element |
getChildElement(java.lang.String sElementName,
org.w3c.dom.Element elmParent)
Return the child element of elm with the name sElementName. |
static org.w3c.dom.Element |
getChildElement(java.lang.String sElementName,
org.w3c.dom.Element elmParent,
boolean bIgnoreCase)
Return the child element of elm with the name sElementName. |
static java.lang.String |
getStringFromNode(org.w3c.dom.Node node,
java.lang.String concatString)
Convenience method for returning result of getTextFromNode(0) as String. |
static java.lang.StringBuffer |
getTextFromNode(org.w3c.dom.Node node,
java.lang.String concatString)
Concatenates the text nodes together for the node passed in into a single string. |
static java.lang.String |
getValue(java.lang.String nodeName,
org.w3c.dom.Element parentElement)
Call this to get a specific value out of the configuration document. |
static java.lang.String[] |
getValues(java.lang.String nodeName,
org.w3c.dom.Element parentElement)
Call this to get a set of values out of the configuration document. |
static org.w3c.dom.Document |
getXMLDoc(java.io.File xmlFile)
Reads in a file and passes it to an XML parser from which it will get and return a document object. |
static org.w3c.dom.Document |
getXMLDoc(org.xml.sax.InputSource source)
Reads in an input source and passes it to an XML parser from which it will get and return a document object. |
static org.w3c.dom.Document |
getXMLDoc(java.lang.String xmlDocAsString)
Function that takes a String and returns a Document object. |
static java.lang.String |
replaceInvalidCharWithSpace(java.lang.String input)
Turns invalid characters into spaces. |
static void |
writeXMLDocToFileSys(org.w3c.dom.Document doc,
java.io.File file)
Writes the xml doc to the specified file. |
static java.lang.StringBuffer |
xmlDocToStringBuffer(org.w3c.dom.Document doc)
Function take an XML document, serializes it and returns a string buffer. |
static java.lang.StringBuffer |
xmlDocToStringBuffer(org.w3c.dom.Document doc,
boolean indent)
Function take an XML document, serializes it (with an indented format for viewing) and returns a string buffer. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public XMLUtil()
| Method Detail |
public static java.lang.StringBuffer xmlDocToStringBuffer(org.w3c.dom.Document doc)
throws java.io.IOException
doc - the XML document to be serialized into a string buffer.java.io.IOException - thrown when there is an exception writing the XML document to the string buffer.
public static java.lang.StringBuffer xmlDocToStringBuffer(org.w3c.dom.Document doc,
boolean indent)
throws java.io.IOException
doc - the XML document to be serialized into a string buffer.java.io.IOException - thrown when there is an exception writing the XML document to the string buffer.
public static org.w3c.dom.Document getXMLDoc(java.lang.String xmlDocAsString)
throws java.io.IOException,
org.xml.sax.SAXException
xmlDocAsString - the XML document as a string.java.io.IOException - thrown when there is an exception reading the XML document from the string.SAXException - thrown when there is an error while parsing the XML document.
public static org.w3c.dom.Document getXMLDoc(java.io.File xmlFile)
throws java.io.IOException,
org.xml.sax.SAXException
xmlFile - a file object that represents the file to be read in.java.io.IOException - thrown when there is an exception reading the XML document from the file.SAXException - thrown when there is an error while parsing the XML document.
public static org.w3c.dom.Document getXMLDoc(org.xml.sax.InputSource source)
throws java.io.IOException,
org.xml.sax.SAXException
source - the input source to be parsed into an XML document.java.io.IOException - thrown when there is an exception reading the XML document from the input source.SAXException - thrown when there is an error while parsing the XML document.
public static java.lang.String getStringFromNode(org.w3c.dom.Node node,
java.lang.String concatString)
public static java.lang.StringBuffer getTextFromNode(org.w3c.dom.Node node,
java.lang.String concatString)
node - the node to extract the text nodes from.concatString - the string that will be concatenated between each text node.
public static java.lang.String getValue(java.lang.String nodeName,
org.w3c.dom.Element parentElement)
nodeName - the name of the XML node to retrieve.parentElement - the parent of the node to find and retrieve its values for.
public static java.lang.String[] getValues(java.lang.String nodeName,
org.w3c.dom.Element parentElement)
nodeName - the name of the XML node(s) to retrieve.parentElement - the parent of the node to find and retrieve its values for.public static java.lang.String replaceInvalidCharWithSpace(java.lang.String input)
input - the string to replace invalid characters with spaces.
public static org.w3c.dom.Element getChildElement(java.lang.String sElementName,
org.w3c.dom.Element elmParent)
throws XMLNodeDoesNotExistException
sElementName - the name of the element to be returned.elmParent - the parent Element in which this method will search for a
child element with sElementName as its name.XMLNodeDoesNotExistException - if the requested Element does not exist
in the parent Element.
public static org.w3c.dom.Element getChildElement(java.lang.String sElementName,
org.w3c.dom.Element elmParent,
boolean bIgnoreCase)
throws XMLNodeDoesNotExistException
sElementName - the name of the element to be returned.elmParent - the parent Element in which this method will search for a
child element with sElementName as its name.bIgnoreCase - if true, case is ignored when comparing
the names of child Elements to sElementName.XMLNodeDoesNotExistException - if the requested Element does not exist
in the parent Element.
public static org.w3c.dom.Element addNewChildElement(java.lang.String name,
org.w3c.dom.Element parent)
public static org.w3c.dom.Element addNewChildElement(java.lang.String name,
java.lang.String value,
org.w3c.dom.Element parent)
name - -- name for the new Element.value - -- value for the new Element.parent - -- parent Element of new Element.
public static void addOrReplaceElementText(org.w3c.dom.Element elm,
java.lang.String newValue)
throws XMLNodeDoesNotExistException
public static org.w3c.dom.Element addRootElement(java.lang.String name,
org.w3c.dom.Document parent)
public static void writeXMLDocToFileSys(org.w3c.dom.Document doc,
java.io.File file)
throws java.io.IOException
|
SourceJammer 1.2.0.1 May 20, 2002 Copyright (c) 2001, 2002 Robert MacGrogan |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||