Class 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 a SimpleSAXHandler, which can process the XML events and return an object of a specified type.
    • 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 the SimpleSAXHandler throws 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 the SimpleSAXHandler throws 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 the SimpleSAXHandler throws an exception, then this method will throw that same exception.
        IOException - if a reading error occurs