Top Description Fields Constructors Methods
com.ctc.wstx.stax

public Class WstxInputFactory

extends XMLInputFactory2
implements ReaderCreator, InputConfigFlags
Class Inheritance
All Implemented Interfaces
com.ctc.wstx.cfg.InputConfigFlags, com.ctc.wstx.sr.ReaderCreator
Annotations
@ServiceProvider:XMLInputFactory
Imports
java.io.*, java.net.URL, javax.xml.stream.*, javax.xml.stream.util.XMLEventAllocator, javax.xml.transform.dom.DOMSource, javax.xml.transform.sax.SAXSource, javax.xml.transform.stream.StreamSource, aQute.bnd.annotation.spi.ServiceProvider, org.xml.sax.InputSource, org.codehaus.stax2.XMLEventReader2, .XMLInputFactory2, .XMLStreamReader2, org.codehaus.stax2.io.Stax2Source, .Stax2ByteArraySource, org.codehaus.stax2.ri.Stax2FilteredStreamReader, .Stax2ReaderAdapter, org.codehaus.stax2.ri.evt.Stax2EventReaderAdapter, .Stax2FilteredEventReader, com.ctc.wstx.api.ReaderConfig, .WstxInputProperties, com.ctc.wstx.cfg.InputConfigFlags, .XmlConsts, com.ctc.wstx.dtd.DTDId, .DTDSubset, com.ctc.wstx.dom.WstxDOMWrappingReader, com.ctc.wstx.evt.DefaultEventAllocator, .WstxEventReader, com.ctc.wstx.exc.WstxIOException, com.ctc.wstx.io.*, com.ctc.wstx.sr.ValidatingStreamReader, .ReaderCreator, com.ctc.wstx.util.DefaultXmlSymbolTable, .SimpleCache, .SymbolTable, .URLUtil

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 Summary

Modifier and TypeField and Description
protected XMLEventAllocator
pack-priv static final int
MAX_SYMBOL_TABLE_GENERATIONS

Number of generations should not matter as much as raw size...

pack-priv 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.

protected final ReaderConfig
mConfig

Current configurations for this factory

protected SimpleCache<DTDId, DTDSubset>
pack-priv static final SymbolTable
mRootSymbols

'Root' symbol table, used for creating actual symbol table instances, but never as is.

private SymbolTable
mSymbols

Actual current 'parent' symbol table; concrete instances will be created from this instance using makeChild method

Inherited from org.codehaus.stax2.XMLInputFactory2:
P_AUTO_CLOSE_INPUTP_DTD_OVERRIDEP_INTERN_NAMESP_INTERN_NS_URISP_LAZY_PARSINGP_PRESERVE_LOCATIONP_REPORT_CDATAP_REPORT_PROLOG_WHITESPACE

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public synchronized void
public void
addSymbol(String symbol)

Method that can be used to ensure that specified symbol is contained in the shared symbol table.

public void
configureForConvenience()

Implements abstract org.codehaus.stax2.XMLInputFactory2.configureForConvenience.

Method to call to make Reader created be as "convenient" to use as possible; ie try to avoid having to deal with some of things like segmented text chunks.

public void
configureForLowMemUsage()

Implements abstract org.codehaus.stax2.XMLInputFactory2.configureForLowMemUsage.

Method to call to minimize the memory usage of the stream/event reader; both regarding Objects created, and the temporary memory usage during parsing.

public void
configureForRoundTripping()

Implements abstract org.codehaus.stax2.XMLInputFactory2.configureForRoundTripping.

Method to call to make Reader try to preserve as much of input formatting as possible, so that round-tripping would be as lossless as possible.

public void
configureForSpeed()

Implements abstract org.codehaus.stax2.XMLInputFactory2.configureForSpeed.

Method to call to make the Reader created be as fast as possible reading documents, especially for long-running processes where caching is likely to help.

public void
configureForXmlConformance()

Implements abstract org.codehaus.stax2.XMLInputFactory2.configureForXmlConformance.

Method to call to make Reader created conform as closely to XML standard as possible, doing all checks and transformations mandated by the XML specification (linefeed conversions, attr value normalizations).

protected XMLEventAllocator
public XMLEventReader
createFilteredReader(XMLEventReader
the event reader to wrap
reader
,
EventFilter
the filter to apply to the event reader
filter
)

Implements abstract javax.xml.stream.XMLInputFactory.createFilteredReader.

Create a filtered event reader that wraps the filter around the event reader

public XMLStreamReader
createFilteredReader(XMLStreamReader
the reader to filter
reader
,
StreamFilter
the filter to apply to the reader
filter
)

Implements abstract javax.xml.stream.XMLInputFactory.createFilteredReader.

Create a filtered reader that wraps the filter around the reader

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).

public XMLStreamReader2
createSR(ReaderConfig cfg, String
System id used for this reader (if any)
systemId
,
InputBootstrapper
Bootstrapper to use for creating actual underlying physical reader
bs
,
boolean
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)
forER
,
boolean
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 java.net.URL and java.io.File arguments, or when configuration settings indicate auto-closing is to be enabled (the default value is false as per Stax 1.0 specs).
autoCloseInput
)

Method that is eventually called to create a (full) stream read instance.

public XMLStreamReader2
createSR(ReaderConfig cfg, SystemId systemId, InputBootstrapper bs, boolean forER, boolean autoCloseInput)

protected XMLStreamReader2
createSR(SystemId systemId, InputStream in, String enc, boolean forER, boolean autoCloseInput)

protected XMLStreamReader2
createSR(ReaderConfig cfg, URL src, boolean forER, boolean autoCloseInput)

private XMLStreamReader2
createSR(ReaderConfig cfg, SystemId systemId, InputStream in, boolean forER, boolean autoCloseInput)

protected XMLStreamReader2
createSR(SystemId systemId, Reader r, boolean forER, boolean autoCloseInput)

protected XMLStreamReader2
createSR(File f, boolean forER, boolean autoCloseInput)

protected XMLStreamReader2
createSR(Source src, boolean
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)
forER
)

Another internal factory method, used when dealing with a generic Source base type.

public XMLEventReader
createXMLEventReader(InputStream
the InputStream to read from
in
)

Implements abstract javax.xml.stream.XMLInputFactory.createXMLEventReader.

Create a new XMLEventReader from a java.io.InputStream

public XMLEventReader
createXMLEventReader(InputStream
the InputStream to read from
in
,
String
the character encoding of the stream
enc
)

Implements abstract javax.xml.stream.XMLInputFactory.createXMLEventReader.

Create a new XMLEventReader from a java.io.InputStream

public XMLEventReader
createXMLEventReader(Reader
the XML data to read from
r
)

Implements abstract javax.xml.stream.XMLInputFactory.createXMLEventReader.

Create a new XMLEventReader from a reader.

public XMLEventReader
createXMLEventReader(Source
the source to read from
source
)

Implements abstract javax.xml.stream.XMLInputFactory.createXMLEventReader.

Create a new XMLEventReader from a JAXP source.

public XMLEventReader
createXMLEventReader(String
the system ID of the stream
systemId
,
InputStream
the InputStream to read from
in
)

Implements abstract javax.xml.stream.XMLInputFactory.createXMLEventReader.

Create a new XMLEventReader from a java.io.InputStream

public XMLEventReader
createXMLEventReader(String
the system ID of the input
systemId
,
Reader
the XML data to read from
r
)

Implements abstract javax.xml.stream.XMLInputFactory.createXMLEventReader.

Create a new XMLEventReader from a reader.

public XMLEventReader
createXMLEventReader(XMLStreamReader
the XMLStreamReader to read from (may not be modified)
sr
)

Implements abstract javax.xml.stream.XMLInputFactory.createXMLEventReader.

Create a new XMLEventReader from an XMLStreamReader.

public XMLEventReader2
createXMLEventReader(URL src)

Implements abstract org.codehaus.stax2.XMLInputFactory2.createXMLEventReader.

Factory method that allows for parsing a document accessible via specified URL.

public XMLEventReader2
createXMLEventReader(File f)

Implements abstract org.codehaus.stax2.XMLInputFactory2.createXMLEventReader.

Convenience factory method that allows for parsing a document stored in the specified file.

public XMLStreamReader
createXMLStreamReader(InputStream
the InputStream to read from
in
)

Implements abstract javax.xml.stream.XMLInputFactory.createXMLStreamReader.

Create a new XMLStreamReader from a java.io.InputStream.

public XMLStreamReader
createXMLStreamReader(InputStream
the InputStream to read from
in
,
String
the character encoding of the stream
enc
)

Implements abstract javax.xml.stream.XMLInputFactory.createXMLStreamReader.

Create a new XMLStreamReader from a java.io.InputStream.

public XMLStreamReader
createXMLStreamReader(Reader
the XML data to read from
r
)

Implements abstract javax.xml.stream.XMLInputFactory.createXMLStreamReader.

Create a new XMLStreamReader from a reader.

public XMLStreamReader
createXMLStreamReader(Source
the source to read from
src
)

Implements abstract javax.xml.stream.XMLInputFactory.createXMLStreamReader.

Create a new XMLStreamReader from a JAXP source.

public XMLStreamReader
createXMLStreamReader(String
the system ID of the stream
systemId
,
InputStream
the InputStream to read from
in
)

Implements abstract javax.xml.stream.XMLInputFactory.createXMLStreamReader.

Create a new XMLStreamReader from a java.io.InputStream.

public XMLStreamReader
createXMLStreamReader(String
the system ID of the stream
systemId
,
Reader
the InputStream to read from
r
)

Implements abstract javax.xml.stream.XMLInputFactory.createXMLStreamReader.

Create a new XMLStreamReader from a java.io.InputStream.

public XMLStreamReader2
createXMLStreamReader(URL src)

Implements abstract org.codehaus.stax2.XMLInputFactory2.createXMLStreamReader.

Factory method that allows for parsing a document accessible via specified URL.

public XMLStreamReader2
createXMLStreamReader(File f)

Implements abstract org.codehaus.stax2.XMLInputFactory2.createXMLStreamReader.

Convenience factory method that allows for parsing a document stored in the specified file.

private XMLStreamReader2
doCreateSR(ReaderConfig cfg, SystemId systemId, InputBootstrapper bs, boolean
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)
forER
,
boolean
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 java.net.URL and java.io.File arguments, or when configuration settings indicate auto-closing is to be enabled (the default value is false as per Stax 1.0 specs).
autoCloseInput
)

Bottleneck method used for creating ALL full stream reader instances (via other createSR() methods and directly)

public synchronized DTDSubset
findCachedDTD(DTDId id)

Implements com.ctc.wstx.sr.ReaderCreator.findCachedDTD.

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.

public ReaderConfig
public XMLEventAllocator
getEventAllocator()

Implements abstract javax.xml.stream.XMLInputFactory.getEventAllocator.

Gets the allocator used by streams created with this factory

public Object
getProperty(String
The name of the property (may not be null)
name
)

Implements abstract javax.xml.stream.XMLInputFactory.getProperty.

Get the value of a feature/property from the underlying implementation

public XMLReporter
getXMLReporter()

Implements abstract javax.xml.stream.XMLInputFactory.getXMLReporter.

The reporter that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.

public XMLResolver
getXMLResolver()

Implements abstract javax.xml.stream.XMLInputFactory.getXMLResolver.

The resolver that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.

public boolean
isPropertySupported(String
The name of the property (may not be null)
name
)

Implements abstract javax.xml.stream.XMLInputFactory.isPropertySupported.

Query the set of properties that this factory supports.

public void
setEventAllocator(XMLEventAllocator
the user defined allocator
allocator
)

Implements abstract javax.xml.stream.XMLInputFactory.setEventAllocator.

Set a user defined event allocator for events

public void
setProperty(String
The name of the property (may not be null)
propName
,
Object
The value of the property
value
)

Implements abstract javax.xml.stream.XMLInputFactory.setProperty.

Allows the user to set specific feature/property on the underlying implementation.

public void
setXMLReporter(XMLReporter
the resolver to use to report non fatal errors
r
)

Implements abstract javax.xml.stream.XMLInputFactory.setXMLReporter.

The reporter that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.

public void
setXMLResolver(XMLResolver
the resolver to use to resolve references
r
)

Implements abstract javax.xml.stream.XMLInputFactory.setXMLResolver.

Note

it's preferable to use Wstx-specific ReaderConfig#setEntityResolver instead, if possible, since this just wraps passed in resolver.

public synchronized void
updateSymbolTable(SymbolTable t)

Implements com.ctc.wstx.sr.ReaderCreator.updateSymbolTable.

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.