|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.peace_tools.workspace.DOMHelper
public class DOMHelper
This class contains a collection of static utility method that are used to retrieve or create elements in a given DOM tree. All the methods in this class are static methods and can be directly invoked. This class is not meant to be (and cannot be) instantiated.
Field Summary | |
---|---|
static java.lang.String |
PEACE_NS
This string defines the name space for the XML elements created by the utility methods. |
Constructor Summary | |
---|---|
private |
DOMHelper()
This class is not meant to be instantiated. |
Method Summary | |
---|---|
static org.w3c.dom.Element |
addElement(org.w3c.dom.Element parent,
java.lang.String name,
java.lang.String value)
Helper method to add a new element to a given DOM node. |
static org.w3c.dom.Element |
getElement(org.w3c.dom.Document parent,
java.lang.String childName)
Utility method to search for a given immediate child element. |
static org.w3c.dom.Element |
getElement(org.w3c.dom.Element parent,
java.lang.String childName)
Utility method to search for a given immediate child element. |
private static org.w3c.dom.Element |
getElement(org.w3c.dom.NodeList nodes,
java.lang.String elementName)
Helper method to search within a given list of nodes to locate a given element. |
static int |
getIntValue(org.w3c.dom.Element parent,
java.lang.String elementName)
Utility method to obtain the value of a given element as an integer. |
static java.lang.String |
getStringValue(org.w3c.dom.Document domDoc,
java.lang.String elementName)
Utility method to obtain the value of a given element as a string. |
static java.lang.String |
getStringValue(org.w3c.dom.Element parent,
java.lang.String elementName)
Utility method to obtain the value of a given element as a string. |
static java.lang.String |
getStringValue(org.w3c.dom.Element parent,
java.lang.String elementName,
boolean canBeNull)
Utility method to obtain the value of a given element as a string. |
static java.lang.String |
getStringValue(org.w3c.dom.NodeList nodes,
java.lang.String elementName,
boolean canBeNull)
Utility method to obtain the value of a given element as a String. |
static boolean |
hasElement(org.w3c.dom.Element parent,
java.lang.String elementName)
Utility method to determine if a given DOM element has an optional sub-element. |
static java.lang.String |
xmlEncode(java.lang.String text)
Encodes any text as PCDATA. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String PEACE_NS
Constructor Detail |
---|
private DOMHelper()
Method Detail |
---|
public static java.lang.String getStringValue(org.w3c.dom.Document domDoc, java.lang.String elementName)
Note: This method does not recursively search child elements. Only the immediate underlying child elements are searched.
domDoc
- The root of the DOM document tree whose immediate underlying
child elements are to be searched.elementName
- The name of the element whose value is to be converted
to an integer and returned.
public static java.lang.String getStringValue(org.w3c.dom.Element parent, java.lang.String elementName)
Note: This method does not recursively search its child elements. Only the immediate underlying child elements are searched.
parent
- The parent element whose immediate child elements are to
be searched.elementName
- The name of the element whose value is to be converted
to an integer and returned.
public static java.lang.String getStringValue(org.w3c.dom.Element parent, java.lang.String elementName, boolean canBeNull)
Note: This method does not recursively search its child elements. Only the immediate underlying child elements are searched.
parent
- The parent element whose immediate child elements are to
be searched.elementName
- The name of the element whose value is to be converted
to an integer and returned.canBeNull
- This flag indicates that the data can be null.
public static java.lang.String getStringValue(org.w3c.dom.NodeList nodes, java.lang.String elementName, boolean canBeNull)
Note: This method does not recursively search the list of nodes. It only checks the given list of nodes.
nodes
- The list of nodes to be searched.elementName
- The name of the element whose value is to be returned
as a String.canBeNull
- This flag indicates that the data can be null.
public static int getIntValue(org.w3c.dom.Element parent, java.lang.String elementName)
Note: This method does not recursively search its child elements. Only the immediate underlying child elements are searched.
parent
- The parent element whose immediate child elements are to
be searched.elementName
- The name of the element whose value is to be converted
to an integer and returned.
public static boolean hasElement(org.w3c.dom.Element parent, java.lang.String elementName)
parent
- The DOM element within which to search.elementName
- The name of element to be located and returned.
public static org.w3c.dom.Element getElement(org.w3c.dom.Document parent, java.lang.String childName)
parent
- The root DOM document within which to search.childName
- The name of element to be located and returned.
public static org.w3c.dom.Element getElement(org.w3c.dom.Element parent, java.lang.String childName)
parent
- The parent DOM element within which to search.childName
- The name of element to be located and returned.
private static org.w3c.dom.Element getElement(org.w3c.dom.NodeList nodes, java.lang.String elementName)
Note: This method does not search recursively within the list of nodes. Only the immediately underlying child elements are searched for a match.
nodes
- The list of DOM nodes in which to search for a given element.elementName
- The name of element to search for.
public static org.w3c.dom.Element addElement(org.w3c.dom.Element parent, java.lang.String name, java.lang.String value)
parent
- The DOM element to which a new element is to be added.name
- The name of the new element to be added to the DOM tree.value
- The value to be associated with the new element.
public static final java.lang.String xmlEncode(java.lang.String text)
text
- The text to be encoded to XML. If this parameter is
null, this method immediately exits with null.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |