Class XMLUtil
java.lang.Object
games.stendhal.server.core.config.XMLUtil
XML utility methods for DOM reading.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
checkCondition(String condition)
checks if a condition is truestatic Element
createChildElement(Element parent, String name, List<String> order)
creates a child element at the specified positionstatic Element
getElement(Element parent, String name)
Retrieve first element found.getElements(Element parent)
Get all the direct children elements of an element.getElements(Element parent, String name)
Get all the direct children elements of an element that have a specific tag name.static String
Get the direct text content of an element.static void
getText(Element element, StringBuilder sbuf, boolean decend)
Get the text content of an element.static Document
parse(InputStream in)
Parse an XML document.static Document
parse(InputSource is)
Parse an XML document.static void
writes an xml document to a file
-
Constructor Details
-
XMLUtil
public XMLUtil()
-
-
Method Details
-
getElements
Get all the direct children elements of an element.- Parameters:
parent
- The parent element.- Returns:
- A list of Element's.
-
getElements
Get all the direct children elements of an element that have a specific tag name.- Parameters:
parent
- The parent element.name
- The tag name to match.- Returns:
- A list of Element's.
-
getElement
Retrieve first element found. -
getText
Get the direct text content of an element.- Parameters:
element
- The element.- Returns:
- The contained text.
-
getText
Get the text content of an element.- Parameters:
element
- The element.sbuf
- The buffer to append to.decend
- Whether to descend into child elements.
-
createChildElement
creates a child element at the specified position- Parameters:
parent
- parent elementname
- name of new child elementorder
- order of elements to insert the new child element at the correct position- Returns:
- newly created child element
-
parse
Parse an XML document.- Parameters:
in
- The input stream.- Returns:
- A Document.
- Throws:
SAXException
- If there is a parsing error.IOException
- If there is an I/O error.IllegalArgumentException
- If there is a parser configuration error.
-
parse
Parse an XML document.- Parameters:
is
- The input source.- Returns:
- A Document.
- Throws:
SAXException
- If there is a parsing error.IOException
- If there is an I/O error.IllegalArgumentException
- If there is a parser configuration error.
-
writeFile
public static void writeFile(Document document, String filename) throws IOException, TransformerExceptionwrites an xml document to a file- Parameters:
document
- DOM documentfilename
- filename- Throws:
IOException
- in case of an input/output errorTransformerException
- in case of an transformation issue
-
checkCondition
checks if a condition is true- Parameters:
condition
- value of the condition attribute- Returns:
- result of the evaluation of the condition
-