Class StreamingParserFactory

  • Direct Known Subclasses:
    StreamingParserFactoryImpl

    public abstract class StreamingParserFactory
    extends Object
    Factory class for creating demand-driven parsers. In typical use an instance of this class is created and configured, and then it is used to create parser instances as required, like so:
         StreamingParserFactory spf
             = StreamingParserFactory.newInstance();
         pf.setValidating(true);
         pf.setCoalescing(false);
         StreamingParser sp = spf.newParser(in);
    Author:
    Mark Reinhold, JAX-RPC RI Development Team
    • Constructor Detail

      • StreamingParserFactory

        protected StreamingParserFactory()
    • Method Detail

      • newInstance

        public static StreamingParserFactory newInstance()
        Creates a new factory of demand-driven parsers.
      • setValidating

        public abstract void setValidating​(boolean validating)
        Sets the validating property of this factory.
        Parameters:
        validating - Parsers henceforth created by this factory will perform validation if, and only if, this parameter is true
        Throws:
        UnsupportedOperationException - If the parser implementation does not support the requested value
      • isValidating

        public abstract boolean isValidating()
        Returns the validating property of this factory.
        Returns:
        true if, and only if, all parsers henceforth created by this factory will perform validation
      • setCoalescing

        public abstract void setCoalescing​(boolean coalescing)
        Sets the coalescing property of this factory. If coalescing is enabled then the parser will always coalesce adjacent runs of character data, i.e., the StreamingParser.CHARS state will never occur more than once in sequence.
        Parameters:
        coalescing - Parsers henceforth created by this factory will coalesce character data if, and only if, this parameter is true
        Throws:
        UnsupportedOperationException - If the parser implementation does not support the requested value
      • isCoalescing

        public abstract boolean isCoalescing()
        Returns the coalescing property of this factory.
        Returns:
        true if, and only if, all parsers henceforth created by this factory will coalesce adjacent runs of character data
      • setNamespaceAware

        public abstract void setNamespaceAware​(boolean namespaceAware)
        Sets the namespaceAware property of this factory.
        Parameters:
        namespaceAware - Parsers henceforth created by this factory will support namespace if, and only if, this parameter is true
        Throws:
        UnsupportedOperationException - If the parser implementation does not support the requested value
      • isNamespaceAware

        public abstract boolean isNamespaceAware()
        Returns the namespaceAware property of this factory.
        Returns:
        true if, and only if, all parsers henceforth created by this factory will support namespace
      • newParser

        public abstract StreamingParser newParser​(InputStream in)
        Creates a new parser instance that reads from the given input stream. No parsing is done by this method; the parse method of the resulting parser must be invoked to parse the initial component of the input document.
        Parameters:
        in - The input stream from which the XML document will be read
      • newParser

        public abstract StreamingParser newParser​(File file)
                                           throws IOException
        Creates a new demand-driven parser that reads from the given file. No parsing is done by this constructor; the parse method must be invoked to parse the initial component of the given document.
        Parameters:
        file - The file from which the XML document will be read
        Throws:
        IOException - If an I/O error occurs