class XmlUtils
extends java.lang.Object
| Constructor and Description |
|---|
XmlUtils() |
| Modifier and Type | Method and Description |
|---|---|
static void |
checkElementName(org.w3c.dom.Element element,
java.lang.String expected)
Check the element has the expected name.
|
static void |
ensureNotEmpty(java.lang.String string,
java.lang.String objectName)
Verify the string is not empty.
|
static void |
ensureNotNull(java.lang.Object object,
java.lang.String objectName)
Verify the passed object is not null.
|
static java.lang.String |
getAtribute(org.w3c.dom.Element element,
java.lang.String name)
Get a value of an attribute.
|
static java.util.List<org.w3c.dom.Element> |
getElements(org.w3c.dom.Element element,
java.lang.String name)
Get all subelements with a concrete name.
|
static org.w3c.dom.Element |
getOneElement(org.w3c.dom.Element element,
java.lang.String name)
Get one subelement with a concrete name.
|
static org.w3c.dom.Element |
getOneOptionalElement(org.w3c.dom.Element element,
java.lang.String name)
Get one optional subelement with a concrete name.
|
static java.lang.String |
getOptionalAtribute(org.w3c.dom.Element element,
java.lang.String name)
Get a value of an optional attribute.
|
static java.lang.String |
getOptionalText(org.w3c.dom.Element element)
Get optional text located inside an element.
|
static java.lang.String |
getText(org.w3c.dom.Element element)
Get text located inside an element.
|
static boolean |
toBoolean(java.lang.String string)
Parse string to a boolean value.
|
static double |
toDouble(java.lang.String string)
Parse string to a double value.
|
static org.w3c.dom.Element |
toElement(org.w3c.dom.Node node)
Convert a node to an element.
|
static int |
toInt(java.lang.String string)
Parse string to an integer value.
|
public static void ensureNotNull(java.lang.Object object,
java.lang.String objectName)
throws QfsmException
object - the objectobjectName - the object nameQfsmException - if the object is nullpublic static void ensureNotEmpty(java.lang.String string,
java.lang.String objectName)
throws QfsmException
string - the stringobjectName - the string nameQfsmException - if the string is emptypublic static void checkElementName(org.w3c.dom.Element element,
java.lang.String expected)
throws QfsmException
element - the elementexpected - the expected nameQfsmException - if the element name differs from the expected onepublic static org.w3c.dom.Element toElement(org.w3c.dom.Node node)
throws QfsmException
node - the nodeQfsmException - if the node is not elementpublic static org.w3c.dom.Element getOneElement(org.w3c.dom.Element element,
java.lang.String name)
throws QfsmException
element - the parent elementname - the subelement nameQfsmException - if the element is not defined or if more than one element of
this name is definedpublic static org.w3c.dom.Element getOneOptionalElement(org.w3c.dom.Element element,
java.lang.String name)
throws QfsmException
element - the parent elementname - the subelement nameQfsmException - if more than one element of this name is definedpublic static java.util.List<org.w3c.dom.Element> getElements(org.w3c.dom.Element element,
java.lang.String name)
throws QfsmException
element - the parent elementname - the subelements nameQfsmException - if something failspublic static java.lang.String getText(org.w3c.dom.Element element)
throws QfsmException
element - the parent elementQfsmException - if the text is emptypublic static java.lang.String getOptionalText(org.w3c.dom.Element element)
throws QfsmException
element - the parent elementQfsmException - if something failspublic static java.lang.String getAtribute(org.w3c.dom.Element element,
java.lang.String name)
throws QfsmException
element - the parent elementname - the attribute nameQfsmException - if the attribute is not definedpublic static java.lang.String getOptionalAtribute(org.w3c.dom.Element element,
java.lang.String name)
throws QfsmException
element - the parent elementname - the attribute nameQfsmException - if something failspublic static int toInt(java.lang.String string)
throws QfsmException
string - the stringQfsmException - if the parsing failspublic static double toDouble(java.lang.String string)
throws QfsmException
string - the stringQfsmException - if the parsing failspublic static boolean toBoolean(java.lang.String string)
throws QfsmException
0, false, no, 1, true, yes independent to case.string - the stringQfsmException - if the parsing failsCopyright 2013 Michal Turek, AnotherFSM.