|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.mtu.eggplant.xml.XMLUtils
public class XMLUtils
Some utilities for working with XML.
Field Summary | |
---|---|
static DocumentBuilder |
DOCUMENT_BUILDER
|
static ThreadLocal<DateFormat> |
XML_TIME_FORMAT
Date format for time type. |
Constructor Summary | |
---|---|
XMLUtils()
|
Method Summary | |
---|---|
static Boolean |
getBooleanAttributeValue(Element element,
String attributeName)
|
static Double |
getDoubleAttributeValue(Element element,
String attributeName)
Get a double value from an attribute. |
static String |
getStringAttributeValue(Element element,
String attributeName)
|
static Document |
parse(Reader stream,
Schema schema)
Parse the document from the given stream. |
static Document |
parseXMLDocument(InputStream xmlDocStream)
Parse xmlDoc an XML document. |
static void |
writeXML(Document doc,
Writer writer)
Write the document to a writer. |
static void |
writeXML(Document doc,
Writer writer,
String encoding)
Write the document to a writer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final ThreadLocal<DateFormat> XML_TIME_FORMAT
public static final DocumentBuilder DOCUMENT_BUILDER
Constructor Detail |
---|
public XMLUtils()
Method Detail |
---|
public static Document parse(Reader stream, Schema schema) throws IOException, SAXException
stream
- a stream containing document
IOException
- if there is an error reading the stream
SAXException
- if there is an error parsing the document or it
doesn't match the schema
RuntimeException
- if there is an error configuring the XML parser,
this shouldn't happenpublic static Document parseXMLDocument(InputStream xmlDocStream) throws SAXException, IOException
IOException
- if there is an error reading the stream
SAXException
- if the document is found to be invalid
RuntimeException
- if there is an error configuring the XML parser,
this shouldn't happenpublic static String getStringAttributeValue(Element element, String attributeName)
getDoubleAttributeValue(Element, String)
public static Boolean getBooleanAttributeValue(Element element, String attributeName)
getDoubleAttributeValue(Element, String)
public static Double getDoubleAttributeValue(Element element, String attributeName)
element
- the element to get the attribute from, may be nullattributeName
- the attribute name to get
public static void writeXML(Document doc, Writer writer)
doc
- the document to writewriter
- where to write the documentpublic static void writeXML(Document doc, Writer writer, String encoding)
doc
- the document to writewriter
- where to write the documentencoding
- if non-null use this as the encoding for the text
RuntimeException
- if a TransformerException
occurs.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |