Package eu.woolplatform.utils.xml
Class SimpleSAXParser<T>
- java.lang.Object
-
- eu.woolplatform.utils.xml.SimpleSAXParser<T>
-
- Type Parameters:
T- the type of object to return after parsing
public class SimpleSAXParser<T> extends Object
This class can parse an XML document using a SAX parser. At construction it takes aSimpleSAXHandler, which can process the XML events and return an object of a specified type.
-
-
Constructor Summary
Constructors Constructor Description SimpleSAXParser(SimpleSAXHandler<? extends T> handler)Constructs a new SAX handler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tparse(File f)Parses the specified XML file and returns the corresponding object.Tparse(String xml)Parses the specified XML code and returns the corresponding object.Tparse(InputSource input)Parses the specified XML code and returns the corresponding object.
-
-
-
Constructor Detail
-
SimpleSAXParser
public SimpleSAXParser(SimpleSAXHandler<? extends T> handler)
Constructs a new SAX handler. It will forward calls to the specified simple handler.- Parameters:
handler- the simple SAX handler
-
-
Method Detail
-
parse
public T parse(String xml) throws ParseException, IOException
Parses the specified XML code and returns the corresponding object.- Parameters:
xml- the XML code- Returns:
- the object corresponding to the XML code
- Throws:
ParseException- if a parsing error occurs. If theSimpleSAXHandlerthrows an exception, then this method will throw that same exception.IOException- if a reading error occurs
-
parse
public T parse(File f) throws ParseException, IOException
Parses the specified XML file and returns the corresponding object.- Parameters:
f- the XML file- Returns:
- the object corresponding to the XML code
- Throws:
ParseException- if a parsing error occurs. If theSimpleSAXHandlerthrows an exception, then this method will throw that same exception.IOException- if a reading error occurs
-
parse
public T parse(InputSource input) throws ParseException, IOException
Parses the specified XML code and returns the corresponding object.- Parameters:
input- the XML code- Returns:
- the object corresponding to the XML code
- Throws:
ParseException- if a parsing error occurs. If theSimpleSAXHandlerthrows an exception, then this method will throw that same exception.IOException- if a reading error occurs
-
-