|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectch.javasoft.xml.config.XmlUtil
public class XmlUtil
| Method Summary | |
|---|---|
static void |
checkExpectedAttributeValue(Element element,
XmlNode attribute,
String expectedValue)
Check whether the given element has the desired value for a specific attribute. |
static void |
checkExpectedElementName(Element element,
XmlNode expected)
Check whether the given element has the desired name. |
static Element |
getChildElementByAttributeValue(Element element,
XmlNode child,
XmlNode attribute,
String attributeValue,
boolean throwExceptionIfNull)
Returns the child element of the given type which has the desired attribute value in the given attribute. |
static Iterator<Element> |
getChildElements(Element element,
XmlNode childType)
Returns a typed iterator for child elements of a certain type |
static String |
getElementPath(Element elem,
boolean recurseParents)
Returns an xpath like string for the given xml element |
static String |
getNodePath(Node node,
boolean recurseParents)
Returns an xpath like string for the given xml node |
static String |
getOptionalAttributeValue(Element element,
XmlNode attribute,
String defaultValue)
Returns the desired attribute value, or the given default value if no such attribute exists. |
static Element |
getOptionalSingleChildElement(Element element,
XmlNode child)
Returns the desired single child element, or throws an exception if none or multiple are found. |
static String |
getRequiredAttributeValue(Element element,
XmlNode attribute)
Returns the desired attribute value, or throws an exception no such attribute exists. |
static Element |
getRequiredSingleChildElement(Element element,
XmlNode child)
Returns the desired single child element, or throws an exception if none or multiple are found. |
static boolean |
isExpectedElementName(Element element,
XmlNode expected)
Returns true if the given element has the desired name. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static Element getChildElementByAttributeValue(Element element,
XmlNode child,
XmlNode attribute,
String attributeValue,
boolean throwExceptionIfNull)
throws XmlConfigException
/child[@attribute=$attributeValue]
If multiple children match the criteria, an exception is thrown. If no
child matching the criteria is found, then either null is
returned (if throwExceptionIfNull==false), or an exception
is thrown (otherwise).
element - the parent element containing the desired
child elementchild - specifies the name of the child elementattribute - specifies the name of the identifying attributeattributeValue - the desired attribute valuethrowExceptionIfNull - if true, an exception is thrown
if no child matches the criteria
null if
throwExceptionIfNull==false and
no child element matched the criteria
XmlConfigException - If multiple matches occur, or if no match
was found and exception throwing is desired
for this case (see throwExceptionIfNull)
public static Iterator<Element> getChildElements(Element element,
XmlNode childType)
throws XmlConfigException
element - parent of which certain child elements are desiredchildType - node defining the name of the desired child elements
XmlConfigException
public static Element getRequiredSingleChildElement(Element element,
XmlNode child)
throws XmlConfigException
element - the parent of the desired childchild - specifies the desired child element name
XmlConfigException - if no or multiple children match the
criteria
public static Element getOptionalSingleChildElement(Element element,
XmlNode child)
throws XmlConfigException
element - the parent of the desired childchild - specifies the desired child element name
XmlConfigException - if no or multiple children match the
criteria
public static String getRequiredAttributeValue(Element element,
XmlNode attribute)
throws XmlConfigException
element - the element to get the attribute value fromattribute - specifies the desired attribute name
XmlConfigException - if no such attribute value is defined
public static String getOptionalAttributeValue(Element element,
XmlNode attribute,
String defaultValue)
throws XmlConfigException
element - the element to get the attribute value fromattribute - specifies the desired attribute namedefaultValue - the default value to use if no such
attribute exists
XmlConfigException
public static void checkExpectedElementName(Element element,
XmlNode expected)
throws XmlConfigException
element - the element to checkexpected - specifies the expected element name
XmlConfigException - if the check fails
public static boolean isExpectedElementName(Element element,
XmlNode expected)
element - the element to checkexpected - specifies the expected element name
public static void checkExpectedAttributeValue(Element element,
XmlNode attribute,
String expectedValue)
throws XmlConfigException
element - the element to checkattribute - specifies the attribute nameexpectedValue - the desired attribute value
XmlConfigException - if the check fails
public static String getNodePath(Node node,
boolean recurseParents)
node - the node to convert to a stringrecurseParents - true if parents should be included
public static String getElementPath(Element elem,
boolean recurseParents)
elem - the element to convert to a stringrecurseParents - true if parents should be included
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||