|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--uk.org.ogsadai.activity.xmldb.ElementParser
This class contains helper methods for parsing activity elements and throwing useful UserExceptions if they are invalid.
| Constructor Summary | |
ElementParser()
|
|
| Method Summary | |
static org.w3c.dom.Element |
getChildElement(org.w3c.dom.Element parent,
java.lang.String childName)
Gets the first named child element of the specified parent. |
static org.w3c.dom.Element |
getChildElement(org.w3c.dom.Element parent,
java.lang.String namespaceURI,
java.lang.String childName)
Gets the named child element of the specified parent. |
static java.lang.String |
getChildElementAttribute(org.w3c.dom.Element parent,
java.lang.String childName,
java.lang.String attributeName)
Gets the named attribute of the named child element of the specified parent. |
static java.util.List |
getChildElements(org.w3c.dom.Element parent)
Gets a list of all the child elements of the specified parent. |
static java.lang.String |
getChildText(org.w3c.dom.Element parent,
java.lang.String childName)
Gets the concatenated text children, trimmed of surrounding whitespace, of the named child element of the specified parent. |
static java.lang.String |
getChildText(org.w3c.dom.Node parent)
Gets a text representation of the children of the specified parent Node trimmed of any surrounding whitespace. |
static java.lang.String |
parseAttribute(org.w3c.dom.Element element,
java.lang.String attributeName,
boolean nonEmpty)
Parses the value of an attribute of an element. |
static java.lang.String |
parseChildElementAttribute(org.w3c.dom.Element parent,
java.lang.String childName,
java.lang.String attributeName,
boolean required,
boolean nonEmpty)
Parses the value of an attribute of a child element. |
static java.util.List |
parseChildElements(org.w3c.dom.Element parent,
int number)
Parses the child elements of the specified parent. |
static java.lang.String |
parseChildElementValue(org.w3c.dom.Element parent,
java.lang.String childName,
boolean required,
boolean nonEmpty)
Parses the value of a child element of the specified parent. |
static java.lang.String |
parseElementValue(org.w3c.dom.Element element,
boolean nonEmpty)
Parses the specified element and returns its value. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public ElementParser()
| Method Detail |
public static java.lang.String parseElementValue(org.w3c.dom.Element element,
boolean nonEmpty)
throws CommonUserException,
CommonSystemException
nonEmpty flag can be used to control the parsing validation.
element - The Element containing the value.nonEmpty - Set to true if element must contain
a value, otherwise false.
String value. If
nonEmpty is set to false then this
may be null.
CommonUserException - If the value should not be empty but is.
CommonSystemException - If there is a system problem parsing the value.
public static java.lang.String parseChildElementValue(org.w3c.dom.Element parent,
java.lang.String childName,
boolean required,
boolean nonEmpty)
throws CommonUserException,
CommonSystemException
required and nonEmpty flags should be set to
control the validation during the parsing.
parent - The parent Element that may contain
the child.childName - The name of the child element.required - Set to true if the child element is required,
false otherwise.nonEmpty - Set to true if the value of the child element
(if it exists) can not be empty, false otherwise.
CommonUserException - If the parsing validation is not satisfied.
CommonSystemException - If there is a system problem while parsing.
public static java.lang.String parseAttribute(org.w3c.dom.Element element,
java.lang.String attributeName,
boolean nonEmpty)
throws CommonUserException
element - The Element containing the attribute.attributeName - The name of the attribute.nonEmpty - Set to true if the attribute requires a value,
false otherwise.
CommonUserException - If the parsing validation is not satisfied.
public static java.lang.String parseChildElementAttribute(org.w3c.dom.Element parent,
java.lang.String childName,
java.lang.String attributeName,
boolean required,
boolean nonEmpty)
throws CommonUserException
parent - The parent Element that may contain the
child.childName - The name of the child Element.attributeName - The name of the attribute of the child.required - Set to true if this child element is required, false
otherwise.nonEmpty - Set to true if the value of the attribute of the
child element (if the child element exists) can not
be empty, false otherwise.
CommonUserException - If the parsing validation is not satisfied.
public static java.util.List parseChildElements(org.w3c.dom.Element parent,
int number)
throws CommonUserException
parent - The parent Element containing the
children.number - The number of child elements that there must be.
CommonUserException - If the parsing validation is not satisfied.public static java.util.List getChildElements(org.w3c.dom.Element parent)
parent - The Element containing the children.
List of Element objects.
public static org.w3c.dom.Element getChildElement(org.w3c.dom.Element parent,
java.lang.String childName)
parent - The parent Element.childName - The name of the child element.
Element or null if the child does not
exist.
public static org.w3c.dom.Element getChildElement(org.w3c.dom.Element parent,
java.lang.String namespaceURI,
java.lang.String childName)
parent - The parent Element.namespaceURI - The URI for the namespace of the chile element.childName - The name of the child element.
Element or null if the child does not
exist.
public static java.lang.String getChildElementAttribute(org.w3c.dom.Element parent,
java.lang.String childName,
java.lang.String attributeName)
parent - The parent Element.childName - The name of the child element.attributeName - The name of the attribute of the child.
public static java.lang.String getChildText(org.w3c.dom.Element parent,
java.lang.String childName)
throws CommonSystemException
parent - The parent Element.childName - The name of the child element.
String containing the concatenated text
children, trimmed of surrounding white space, or null
if the parent does not contain the specified child.
CommonSystemException
public static java.lang.String getChildText(org.w3c.dom.Node parent)
throws CommonSystemException
Node trimmed of any surrounding whitespace. This is formed
by converting any child elements into strings and concatenating them with
any additional text or CDATA children.
parent - The parent containing the text or CDATA children.
String representation of the
children. This could be an empty
String.
CommonSystemException - If there is a system problem parsing
the parent node.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||