Class JAXPParser

  • All Implemented Interfaces:
    XMLParser

    public class JAXPParser
    extends java.lang.Object
    implements XMLParser

    Purpose: An implementation of XMLParser using JAXP 1.3 APIs.

    JAXPParser is NOT thread safe.

    • Constructor Summary

      Constructors 
      Constructor Description
      JAXPParser()
      Default constructor.
      JAXPParser​(java.util.Map<java.lang.String,​java.lang.Boolean> parserFeatures)
      This constructor provides way to specify features for parser.
      JAXPParser​(javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory, org.xml.sax.ErrorHandler errorHandler)
      This constructor can increase performance by providing existing documentBuilderFactory and errorHandler.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.xml.sax.EntityResolver getEntityResolver()
      Returns entity resolver of the parser.
      org.xml.sax.ErrorHandler getErrorHandler()
      Returns error handler of the parser.
      int getValidationMode()
      Returns validtion mode of the parser.
      javax.xml.validation.Schema getXMLSchema()
      Returns XML Schema of the parser.
      org.w3c.dom.Document parse​(java.io.File file)
      Parses given file.
      org.w3c.dom.Document parse​(java.io.InputStream inputStream)
      Parses given input stream.
      org.w3c.dom.Document parse​(java.io.Reader reader)
      Parses given reader.
      org.w3c.dom.Document parse​(java.net.URL url)
      Parses given url.
      org.w3c.dom.Document parse​(javax.xml.transform.Source source)
      Parses given source.
      org.w3c.dom.Document parse​(org.xml.sax.InputSource inputSource)
      Parses given input source.
      void setEntityResolver​(org.xml.sax.EntityResolver entityResolver)
      Sets entity resolver for the parser.
      void setErrorHandler​(org.xml.sax.ErrorHandler errorHandler)
      Sets error handler for the parser.
      void setNamespaceAware​(boolean isNamespaceAware)
      Changes namespaceAware behavior of the parser.
      void setValidationMode​(int validationMode)
      Sets validation mode of the parser.
      void setWhitespacePreserving​(boolean isWhitespacePreserving)
      Changes preservation of white spaces.
      void setXMLSchema​(java.net.URL url)
      Sets XML Schema for the parser.
      void setXMLSchema​(javax.xml.validation.Schema schema)
      Sets XML Schema for the parser.
      void setXMLSchemas​(java.lang.Object[] schemas)
      Sets XML Schema(s) for the parser.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • JAXPParser

        public JAXPParser()
        Default constructor.
      • JAXPParser

        public JAXPParser​(javax.xml.parsers.DocumentBuilderFactory documentBuilderFactory,
                          org.xml.sax.ErrorHandler errorHandler)
        This constructor can increase performance by providing existing documentBuilderFactory and errorHandler.
        Parameters:
        documentBuilderFactory - existing document builder factory
        errorHandler - existing error handler
      • JAXPParser

        public JAXPParser​(java.util.Map<java.lang.String,​java.lang.Boolean> parserFeatures)
        This constructor provides way to specify features for parser.
        Parameters:
        parserFeatures - features for parser
    • Method Detail

      • setNamespaceAware

        public void setNamespaceAware​(boolean isNamespaceAware)
        Changes namespaceAware behavior of the parser.
        Specified by:
        setNamespaceAware in interface XMLParser
        Parameters:
        isNamespaceAware - if the parser should be namespace aware
      • setWhitespacePreserving

        public void setWhitespacePreserving​(boolean isWhitespacePreserving)
        Changes preservation of white spaces.
        Specified by:
        setWhitespacePreserving in interface XMLParser
        Parameters:
        isWhitespacePreserving - if the parser should preserve white spaces
      • getValidationMode

        public int getValidationMode()
        Returns validtion mode of the parser.
        Specified by:
        getValidationMode in interface XMLParser
        Returns:
        validation mode of the parser
      • setValidationMode

        public void setValidationMode​(int validationMode)
        Sets validation mode of the parser.
        Specified by:
        setValidationMode in interface XMLParser
        Parameters:
        validationMode - validation mode to set
      • getEntityResolver

        public org.xml.sax.EntityResolver getEntityResolver()
        Returns entity resolver of the parser.
        Specified by:
        getEntityResolver in interface XMLParser
        Returns:
        entity resolver of the parser
      • setEntityResolver

        public void setEntityResolver​(org.xml.sax.EntityResolver entityResolver)
        Sets entity resolver for the parser.
        Specified by:
        setEntityResolver in interface XMLParser
        Parameters:
        entityResolver - entity resolver to set
      • getErrorHandler

        public org.xml.sax.ErrorHandler getErrorHandler()
        Returns error handler of the parser.
        Specified by:
        getErrorHandler in interface XMLParser
        Returns:
        error handler of the parser
      • setErrorHandler

        public void setErrorHandler​(org.xml.sax.ErrorHandler errorHandler)
        Sets error handler for the parser.
        Specified by:
        setErrorHandler in interface XMLParser
        Parameters:
        errorHandler - error handler for the parser
      • setXMLSchema

        public void setXMLSchema​(javax.xml.validation.Schema schema)
                          throws XMLPlatformException
        Sets XML Schema for the parser.
        Specified by:
        setXMLSchema in interface XMLParser
        Parameters:
        schema - schema for the parser
        Throws:
        XMLPlatformException - exception occurred while setting XMLSchema
      • parse

        public org.w3c.dom.Document parse​(org.xml.sax.InputSource inputSource)
                                   throws XMLPlatformException
        Parses given input source.
        Specified by:
        parse in interface XMLParser
        Parameters:
        inputSource - input source to parse
        Returns:
        parsed document
        Throws:
        XMLPlatformException - exception occurred while parsing input source
      • parse

        public org.w3c.dom.Document parse​(java.io.File file)
                                   throws XMLPlatformException
        Parses given file.
        Specified by:
        parse in interface XMLParser
        Parameters:
        file - file to parse
        Returns:
        parsed document
        Throws:
        XMLPlatformException - exception occurred while parsing given file
      • parse

        public org.w3c.dom.Document parse​(java.io.InputStream inputStream)
                                   throws XMLPlatformException
        Parses given input stream.
        Specified by:
        parse in interface XMLParser
        Parameters:
        inputStream - input stream to parse
        Returns:
        parsed document
        Throws:
        XMLPlatformException - exception occurred while parsing input stream
      • parse

        public org.w3c.dom.Document parse​(java.io.Reader reader)
                                   throws XMLPlatformException
        Parses given reader.
        Specified by:
        parse in interface XMLParser
        Parameters:
        reader - reader to parse
        Returns:
        parsed document
        Throws:
        XMLPlatformException - exception occurred while parsing given reader
      • parse

        public org.w3c.dom.Document parse​(javax.xml.transform.Source source)
                                   throws XMLPlatformException
        Parses given source.
        Specified by:
        parse in interface XMLParser
        Parameters:
        source - source to parse
        Returns:
        parsed document
        Throws:
        XMLPlatformException - exception occurred while parsing given source
      • parse

        public org.w3c.dom.Document parse​(java.net.URL url)
                                   throws XMLPlatformException
        Parses given url.
        Specified by:
        parse in interface XMLParser
        Parameters:
        url - url to parse
        Returns:
        parsed document
        Throws:
        XMLPlatformException - exception occurred while parsing stream with given url