Class WstxInputFactory

  • All Implemented Interfaces:
    InputConfigFlags, ReaderCreator, org.codehaus.stax2.XMLStreamProperties

    public class WstxInputFactory
    extends org.codehaus.stax2.XMLInputFactory2
    implements ReaderCreator, InputConfigFlags
    Factory for creating various Stax objects (stream/event reader, writer).

    Currently supported configuration options fall into two categories. First, all properties from XMLInputFactory (such as, say, XMLInputFactory.IS_NAMESPACE_AWARE) are at least recognized, and most are supported. Second, there are additional properties, defined in constant class WstxInputProperties, that are supported. See WstxInputProperties for further explanation of these 'custom' properties.

    Author:
    Tatu Saloranta
    • Field Detail

      • MAX_SYMBOL_TABLE_SIZE

        static final int MAX_SYMBOL_TABLE_SIZE
        Let's limit max size to 3/4 of 16k, since this corresponds to 64k main hash index. This should not be too low, but could perhaps be further lowered?
        See Also:
        Constant Field Values
      • MAX_SYMBOL_TABLE_GENERATIONS

        static final int MAX_SYMBOL_TABLE_GENERATIONS
        Number of generations should not matter as much as raw size... but let's still cap it at some number. 500 generations seems reasonable for flushing (note: does not count uses where no new symbols were added).
        See Also:
        Constant Field Values
      • mConfig

        protected final ReaderConfig mConfig
        Current configurations for this factory
      • mAllocator

        protected javax.xml.stream.util.XMLEventAllocator mAllocator
      • mRootSymbols

        static final SymbolTable mRootSymbols
        'Root' symbol table, used for creating actual symbol table instances, but never as is.
      • mSymbols

        private SymbolTable mSymbols
        Actual current 'parent' symbol table; concrete instances will be created from this instance using makeChild method
    • Constructor Detail

      • WstxInputFactory

        public WstxInputFactory()
    • Method Detail

      • addSymbol

        public void addSymbol​(java.lang.String symbol)
        Method that can be used to ensure that specified symbol is contained in the shared symbol table. This may occasionally be useful in pre-populating symbols; although it is unlikely to be commonly useful.
        Since:
        4.2.1
      • findCachedDTD

        public DTDSubset findCachedDTD​(DTDId id)
        Method readers created by this factory call, if DTD caching is enabled, to see if an external DTD (subset) has been parsed and cached earlier.
        Specified by:
        findCachedDTD in interface ReaderCreator
      • updateSymbolTable

        public void updateSymbolTable​(SymbolTable t)
        Method individual parsers call to pass back symbol table that they updated, which may be useful for other parser to reuse, instead of previous base symbol table.

        Note: parser is only to call this method, if passed-in symbol table was modified, ie new entry/ies were added in addition to whatever was in root table.

        Specified by:
        updateSymbolTable in interface ReaderCreator
      • createFilteredReader

        public javax.xml.stream.XMLEventReader createFilteredReader​(javax.xml.stream.XMLEventReader reader,
                                                                    javax.xml.stream.EventFilter filter)
        Specified by:
        createFilteredReader in class javax.xml.stream.XMLInputFactory
      • createFilteredReader

        public javax.xml.stream.XMLStreamReader createFilteredReader​(javax.xml.stream.XMLStreamReader reader,
                                                                     javax.xml.stream.StreamFilter filter)
                                                              throws javax.xml.stream.XMLStreamException
        Specified by:
        createFilteredReader in class javax.xml.stream.XMLInputFactory
        Throws:
        javax.xml.stream.XMLStreamException
      • createXMLEventReader

        public javax.xml.stream.XMLEventReader createXMLEventReader​(java.io.InputStream in)
                                                             throws javax.xml.stream.XMLStreamException
        Specified by:
        createXMLEventReader in class javax.xml.stream.XMLInputFactory
        Throws:
        javax.xml.stream.XMLStreamException
      • createXMLEventReader

        public javax.xml.stream.XMLEventReader createXMLEventReader​(java.io.InputStream in,
                                                                    java.lang.String enc)
                                                             throws javax.xml.stream.XMLStreamException
        Specified by:
        createXMLEventReader in class javax.xml.stream.XMLInputFactory
        Throws:
        javax.xml.stream.XMLStreamException
      • createXMLEventReader

        public javax.xml.stream.XMLEventReader createXMLEventReader​(java.io.Reader r)
                                                             throws javax.xml.stream.XMLStreamException
        Specified by:
        createXMLEventReader in class javax.xml.stream.XMLInputFactory
        Throws:
        javax.xml.stream.XMLStreamException
      • createXMLEventReader

        public javax.xml.stream.XMLEventReader createXMLEventReader​(javax.xml.transform.Source source)
                                                             throws javax.xml.stream.XMLStreamException
        Specified by:
        createXMLEventReader in class javax.xml.stream.XMLInputFactory
        Throws:
        javax.xml.stream.XMLStreamException
      • createXMLEventReader

        public javax.xml.stream.XMLEventReader createXMLEventReader​(java.lang.String systemId,
                                                                    java.io.InputStream in)
                                                             throws javax.xml.stream.XMLStreamException
        Specified by:
        createXMLEventReader in class javax.xml.stream.XMLInputFactory
        Throws:
        javax.xml.stream.XMLStreamException
      • createXMLEventReader

        public javax.xml.stream.XMLEventReader createXMLEventReader​(java.lang.String systemId,
                                                                    java.io.Reader r)
                                                             throws javax.xml.stream.XMLStreamException
        Specified by:
        createXMLEventReader in class javax.xml.stream.XMLInputFactory
        Throws:
        javax.xml.stream.XMLStreamException
      • createXMLEventReader

        public javax.xml.stream.XMLEventReader createXMLEventReader​(javax.xml.stream.XMLStreamReader sr)
                                                             throws javax.xml.stream.XMLStreamException
        Specified by:
        createXMLEventReader in class javax.xml.stream.XMLInputFactory
        Throws:
        javax.xml.stream.XMLStreamException
      • createXMLStreamReader

        public javax.xml.stream.XMLStreamReader createXMLStreamReader​(java.io.InputStream in)
                                                               throws javax.xml.stream.XMLStreamException
        Specified by:
        createXMLStreamReader in class javax.xml.stream.XMLInputFactory
        Throws:
        javax.xml.stream.XMLStreamException
      • createXMLStreamReader

        public javax.xml.stream.XMLStreamReader createXMLStreamReader​(java.io.InputStream in,
                                                                      java.lang.String enc)
                                                               throws javax.xml.stream.XMLStreamException
        Specified by:
        createXMLStreamReader in class javax.xml.stream.XMLInputFactory
        Throws:
        javax.xml.stream.XMLStreamException
      • createXMLStreamReader

        public javax.xml.stream.XMLStreamReader createXMLStreamReader​(java.io.Reader r)
                                                               throws javax.xml.stream.XMLStreamException
        Specified by:
        createXMLStreamReader in class javax.xml.stream.XMLInputFactory
        Throws:
        javax.xml.stream.XMLStreamException
      • createXMLStreamReader

        public javax.xml.stream.XMLStreamReader createXMLStreamReader​(javax.xml.transform.Source src)
                                                               throws javax.xml.stream.XMLStreamException
        Specified by:
        createXMLStreamReader in class javax.xml.stream.XMLInputFactory
        Throws:
        javax.xml.stream.XMLStreamException
      • createXMLStreamReader

        public javax.xml.stream.XMLStreamReader createXMLStreamReader​(java.lang.String systemId,
                                                                      java.io.InputStream in)
                                                               throws javax.xml.stream.XMLStreamException
        Specified by:
        createXMLStreamReader in class javax.xml.stream.XMLInputFactory
        Throws:
        javax.xml.stream.XMLStreamException
      • createXMLStreamReader

        public javax.xml.stream.XMLStreamReader createXMLStreamReader​(java.lang.String systemId,
                                                                      java.io.Reader r)
                                                               throws javax.xml.stream.XMLStreamException
        Specified by:
        createXMLStreamReader in class javax.xml.stream.XMLInputFactory
        Throws:
        javax.xml.stream.XMLStreamException
      • getProperty

        public java.lang.Object getProperty​(java.lang.String name)
        Specified by:
        getProperty in class javax.xml.stream.XMLInputFactory
      • setProperty

        public void setProperty​(java.lang.String propName,
                                java.lang.Object value)
        Specified by:
        setProperty in class javax.xml.stream.XMLInputFactory
      • getEventAllocator

        public javax.xml.stream.util.XMLEventAllocator getEventAllocator()
        Specified by:
        getEventAllocator in class javax.xml.stream.XMLInputFactory
      • getXMLReporter

        public javax.xml.stream.XMLReporter getXMLReporter()
        Specified by:
        getXMLReporter in class javax.xml.stream.XMLInputFactory
      • getXMLResolver

        public javax.xml.stream.XMLResolver getXMLResolver()
        Specified by:
        getXMLResolver in class javax.xml.stream.XMLInputFactory
      • isPropertySupported

        public boolean isPropertySupported​(java.lang.String name)
        Specified by:
        isPropertySupported in class javax.xml.stream.XMLInputFactory
      • setEventAllocator

        public void setEventAllocator​(javax.xml.stream.util.XMLEventAllocator allocator)
        Specified by:
        setEventAllocator in class javax.xml.stream.XMLInputFactory
      • setXMLReporter

        public void setXMLReporter​(javax.xml.stream.XMLReporter r)
        Specified by:
        setXMLReporter in class javax.xml.stream.XMLInputFactory
      • setXMLResolver

        public void setXMLResolver​(javax.xml.stream.XMLResolver r)
        Note: it's preferable to use Wstx-specific ReaderConfig.setEntityResolver(javax.xml.stream.XMLResolver) instead, if possible, since this just wraps passed in resolver.
        Specified by:
        setXMLResolver in class javax.xml.stream.XMLInputFactory
      • createXMLEventReader

        public org.codehaus.stax2.XMLEventReader2 createXMLEventReader​(java.net.URL src)
                                                                throws javax.xml.stream.XMLStreamException
        Specified by:
        createXMLEventReader in class org.codehaus.stax2.XMLInputFactory2
        Throws:
        javax.xml.stream.XMLStreamException
      • createXMLEventReader

        public org.codehaus.stax2.XMLEventReader2 createXMLEventReader​(java.io.File f)
                                                                throws javax.xml.stream.XMLStreamException
        Specified by:
        createXMLEventReader in class org.codehaus.stax2.XMLInputFactory2
        Throws:
        javax.xml.stream.XMLStreamException
      • createXMLStreamReader

        public org.codehaus.stax2.XMLStreamReader2 createXMLStreamReader​(java.net.URL src)
                                                                  throws javax.xml.stream.XMLStreamException
        Specified by:
        createXMLStreamReader in class org.codehaus.stax2.XMLInputFactory2
        Throws:
        javax.xml.stream.XMLStreamException
      • createXMLStreamReader

        public org.codehaus.stax2.XMLStreamReader2 createXMLStreamReader​(java.io.File f)
                                                                  throws javax.xml.stream.XMLStreamException
        Convenience factory method that allows for parsing a document stored in the specified file.
        Specified by:
        createXMLStreamReader in class org.codehaus.stax2.XMLInputFactory2
        Throws:
        javax.xml.stream.XMLStreamException
      • configureForXmlConformance

        public void configureForXmlConformance()
        Specified by:
        configureForXmlConformance in class org.codehaus.stax2.XMLInputFactory2
      • configureForConvenience

        public void configureForConvenience()
        Specified by:
        configureForConvenience in class org.codehaus.stax2.XMLInputFactory2
      • configureForSpeed

        public void configureForSpeed()
        Specified by:
        configureForSpeed in class org.codehaus.stax2.XMLInputFactory2
      • configureForLowMemUsage

        public void configureForLowMemUsage()
        Specified by:
        configureForLowMemUsage in class org.codehaus.stax2.XMLInputFactory2
      • configureForRoundTripping

        public void configureForRoundTripping()
        Specified by:
        configureForRoundTripping in class org.codehaus.stax2.XMLInputFactory2
      • doCreateSR

        private org.codehaus.stax2.XMLStreamReader2 doCreateSR​(ReaderConfig cfg,
                                                               SystemId systemId,
                                                               InputBootstrapper bs,
                                                               boolean forER,
                                                               boolean autoCloseInput)
                                                        throws javax.xml.stream.XMLStreamException
        Bottleneck method used for creating ALL full stream reader instances (via other createSR() methods and directly)
        Parameters:
        forER - True, if the reader is being constructed to be used by an event reader; false if it is not (or the purpose is not known)
        autoCloseInput - Whether the underlying input source should be actually closed when encountering EOF, or when close() is called. Will be true for input sources that are automatically managed by stream reader (input streams created for URL and File arguments, or when configuration settings indicate auto-closing is to be enabled (the default value is false as per Stax 1.0 specs).
        Throws:
        javax.xml.stream.XMLStreamException
      • createSR

        public org.codehaus.stax2.XMLStreamReader2 createSR​(ReaderConfig cfg,
                                                            java.lang.String systemId,
                                                            InputBootstrapper bs,
                                                            boolean forER,
                                                            boolean autoCloseInput)
                                                     throws javax.xml.stream.XMLStreamException
        Method that is eventually called to create a (full) stream read instance.

        Note: defined as public method because it needs to be called by SAX implementation.

        Parameters:
        systemId - System id used for this reader (if any)
        bs - Bootstrapper to use for creating actual underlying physical reader
        forER - Flag to indicate whether it will be used via Event API (will affect some configuration settings), true if it will be, false if not (or not known)
        autoCloseInput - Whether the underlying input source should be actually closed when encountering EOF, or when close() is called. Will be true for input sources that are automatically managed by stream reader (input streams created for URL and File arguments, or when configuration settings indicate auto-closing is to be enabled (the default value is false as per Stax 1.0 specs).
        Throws:
        javax.xml.stream.XMLStreamException
      • createSR

        public org.codehaus.stax2.XMLStreamReader2 createSR​(ReaderConfig cfg,
                                                            SystemId systemId,
                                                            InputBootstrapper bs,
                                                            boolean forER,
                                                            boolean autoCloseInput)
                                                     throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • createSR

        protected org.codehaus.stax2.XMLStreamReader2 createSR​(SystemId systemId,
                                                               java.io.InputStream in,
                                                               java.lang.String enc,
                                                               boolean forER,
                                                               boolean autoCloseInput)
                                                        throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • createSR

        protected org.codehaus.stax2.XMLStreamReader2 createSR​(ReaderConfig cfg,
                                                               java.net.URL src,
                                                               boolean forER,
                                                               boolean autoCloseInput)
                                                        throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • createSR

        private org.codehaus.stax2.XMLStreamReader2 createSR​(ReaderConfig cfg,
                                                             SystemId systemId,
                                                             java.io.InputStream in,
                                                             boolean forER,
                                                             boolean autoCloseInput)
                                                      throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • createSR

        protected org.codehaus.stax2.XMLStreamReader2 createSR​(SystemId systemId,
                                                               java.io.Reader r,
                                                               boolean forER,
                                                               boolean autoCloseInput)
                                                        throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • createSR

        protected org.codehaus.stax2.XMLStreamReader2 createSR​(java.io.File f,
                                                               boolean forER,
                                                               boolean autoCloseInput)
                                                        throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • createSR

        protected org.codehaus.stax2.XMLStreamReader2 createSR​(javax.xml.transform.Source src,
                                                               boolean forER)
                                                        throws javax.xml.stream.XMLStreamException
        Another internal factory method, used when dealing with a generic Source base type. One thing worth noting is that 'auto-closing' will be enabled if the input source or Reader is constructed (and thus owned) by Woodstox.
        Parameters:
        forER - True, if the reader is being constructed to be used by an event reader; false if it is not (or the purpose is not known)
        Throws:
        javax.xml.stream.XMLStreamException
      • createEventAllocator

        protected javax.xml.stream.util.XMLEventAllocator createEventAllocator()
      • createPrivateConfig

        public ReaderConfig createPrivateConfig()
        Method called to construct a copy of the factory's configuration object, such that two will be unlinked (changes to one are not reflect in the other).

        Note: only public so that other woodstox components outside of this package can access it.