Package org.opencypher.tools.xml
Class XmlParser<Root>
- java.lang.Object
-
- org.opencypher.tools.xml.XmlParser<Root>
-
- Type Parameters:
Root- The type of object that is constructed by the parser.
public final class XmlParser<Root> extends Object
Class for parsing an XML document into an object graph.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classXmlParser.OptionOptions that can be passed to an XML parser.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> XmlParser<T>combine(Class<T> base, XmlParser<? extends T>... parsers)Rootparse(InputStream input, XmlParser.Option... options)Parse the XML document from the given input stream.Rootparse(Reader input, XmlParser.Option... options)Parse the XML document from the given reader.Rootparse(Path input, XmlParser.Option... options)Parse the XML document at the given path.StringtoString()static <T> XmlParser<T>xmlParser(Class<T> root)Create a new XML parser for the given type.
-
-
-
Method Detail
-
xmlParser
public static <T> XmlParser<T> xmlParser(Class<T> root)
Create a new XML parser for the given type.- Type Parameters:
T- the type of object constructed by the parser.- Parameters:
root- the type of object that corresponds to the root element of the XML document the parser should parse.- Returns:
- a new XML parser for the given type.
-
combine
@SafeVarargs public static <T> XmlParser<T> combine(Class<T> base, XmlParser<? extends T>... parsers)
-
parse
public Root parse(Path input, XmlParser.Option... options) throws ParserConfigurationException, SAXException, IOException
Parse the XML document at the given path.- Parameters:
input- the path at which to find the XML document to parse.options- configuration for the XML parser.- Returns:
- the object constructed from parsing the XML document.
- Throws:
ParserConfigurationException- if an XML (SAX) parser cannot be created.SAXException- if parsing the XML document failed.IOException- if reading the XML document failed.
-
parse
public Root parse(Reader input, XmlParser.Option... options) throws ParserConfigurationException, SAXException, IOException
Parse the XML document from the given reader. Note that when parsing from a reader referenced files cannot be resolved, this requires parsing from a file.- Parameters:
input- the reader to read the XML document from.options- configuration for the XML parser.- Returns:
- the object constructed from parsing the XML document.
- Throws:
ParserConfigurationException- if an XML (SAX) parser cannot be created.SAXException- if parsing the XML document failed.IOException- if reading the XML document failed.
-
parse
public Root parse(InputStream input, XmlParser.Option... options) throws ParserConfigurationException, SAXException, IOException
Parse the XML document from the given input stream. Note that when parsing from an input stream referenced files cannot be resolved, this requires parsing from a file.- Parameters:
input- the stream to read the XML document from.options- configuration for the XML parser.- Returns:
- the object constructed from parsing the XML document.
- Throws:
ParserConfigurationException- if an XML (SAX) parser cannot be created.SAXException- if parsing the XML document failed.IOException- if reading the XML document failed.
-
-