Package com.ctc.wstx.stax
Class WstxInputFactory
java.lang.Object
javax.xml.stream.XMLInputFactory
org.codehaus.stax2.XMLInputFactory2
com.ctc.wstx.stax.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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected XMLEventAllocator
(package private) static final int
Number of generations should not matter as much as raw size...(package private) static final int
Let's limit max size to 3/4 of 16k, since this corresponds to 64k main hash index.protected final ReaderConfig
Current configurations for this factoryprotected SimpleCache
<DTDId, DTDSubset> (package private) static final SymbolTable
'Root' symbol table, used for creating actual symbol table instances, but never as is.private SymbolTable
Actual current 'parent' symbol table; concrete instances will be created from this instance usingmakeChild
methodFields inherited from class org.codehaus.stax2.XMLInputFactory2
P_AUTO_CLOSE_INPUT, P_DTD_OVERRIDE, P_INTERN_NAMES, P_INTERN_NS_URIS, P_LAZY_PARSING, P_PRESERVE_LOCATION, P_REPORT_CDATA, P_REPORT_PROLOG_WHITESPACE
Fields inherited from class javax.xml.stream.XMLInputFactory
ALLOCATOR, IS_COALESCING, IS_NAMESPACE_AWARE, IS_REPLACING_ENTITY_REFERENCES, IS_SUPPORTING_EXTERNAL_ENTITIES, IS_VALIDATING, REPORTER, RESOLVER, SUPPORT_DTD
Fields inherited from interface com.ctc.wstx.cfg.InputConfigFlags
CFG_ALLOW_XML11_ESCAPED_CHARS_IN_XML10, CFG_AUTO_CLOSE_INPUT, CFG_CACHE_DTDS, CFG_CACHE_DTDS_BY_PUBLIC_ID, CFG_COALESCE_TEXT, CFG_INTERN_NAMES, CFG_INTERN_NS_URIS, CFG_JAXP_FEATURE_SECURE_PROCESSING, CFG_LAZY_PARSING, CFG_NAMESPACE_AWARE, CFG_NORMALIZE_LFS, CFG_PRESERVE_LOCATION, CFG_REPLACE_ENTITY_REFS, CFG_REPORT_CDATA, CFG_REPORT_PROLOG_WS, CFG_SUPPORT_DTD, CFG_SUPPORT_DTDPP, CFG_SUPPORT_EXTERNAL_ENTITIES, CFG_TREAT_CHAR_REFS_AS_ENTS, CFG_VALIDATE_AGAINST_DTD, CFG_XMLID_TYPING, CFG_XMLID_UNIQ_CHECKS
Fields inherited from interface org.codehaus.stax2.XMLStreamProperties
XSP_IMPLEMENTATION_NAME, XSP_IMPLEMENTATION_VERSION, XSP_NAMESPACE_AWARE, XSP_PROBLEM_REPORTER, XSP_SUPPORT_XMLID, XSP_SUPPORTS_XML11, XSP_V_XMLID_FULL, XSP_V_XMLID_NONE, XSP_V_XMLID_TYPING
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCachedDTD
(DTDId id, DTDSubset extSubset) void
Method that can be used to ensure that specified symbol is contained in the shared symbol table.void
void
void
void
void
protected XMLEventAllocator
createFilteredReader
(XMLEventReader reader, EventFilter filter) createFilteredReader
(XMLStreamReader reader, StreamFilter filter) 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).org.codehaus.stax2.XMLStreamReader2
createSR
(ReaderConfig cfg, SystemId systemId, InputBootstrapper bs, boolean forER, boolean autoCloseInput) private org.codehaus.stax2.XMLStreamReader2
createSR
(ReaderConfig cfg, SystemId systemId, InputStream in, boolean forER, boolean autoCloseInput) org.codehaus.stax2.XMLStreamReader2
createSR
(ReaderConfig cfg, String systemId, InputBootstrapper bs, boolean forER, boolean autoCloseInput) Method that is eventually called to create a (full) stream read instance.protected org.codehaus.stax2.XMLStreamReader2
createSR
(ReaderConfig cfg, URL src, boolean forER, boolean autoCloseInput) protected org.codehaus.stax2.XMLStreamReader2
createSR
(SystemId systemId, InputStream in, String enc, boolean forER, boolean autoCloseInput) protected org.codehaus.stax2.XMLStreamReader2
protected org.codehaus.stax2.XMLStreamReader2
protected org.codehaus.stax2.XMLStreamReader2
Another internal factory method, used when dealing with a generic Source base type.org.codehaus.stax2.XMLEventReader2
createXMLEventReader
(InputStream in, String enc) createXMLEventReader
(String systemId, InputStream in) createXMLEventReader
(String systemId, Reader r) org.codehaus.stax2.XMLEventReader2
createXMLEventReader
(URL src) createXMLEventReader
(Source source) org.codehaus.stax2.XMLStreamReader2
Convenience factory method that allows for parsing a document stored in the specified file.createXMLStreamReader
(InputStream in, String enc) createXMLStreamReader
(String systemId, InputStream in) createXMLStreamReader
(String systemId, Reader r) org.codehaus.stax2.XMLStreamReader2
createXMLStreamReader
(URL src) private org.codehaus.stax2.XMLStreamReader2
doCreateSR
(ReaderConfig cfg, SystemId systemId, InputBootstrapper bs, boolean forER, boolean autoCloseInput) Bottleneck method used for creating ALL full stream reader instances (via other createSR() methods and directly)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.getProperty
(String name) boolean
isPropertySupported
(String name) void
setEventAllocator
(XMLEventAllocator allocator) void
setProperty
(String propName, Object value) void
void
Note: it's preferable to use Wstx-specificReaderConfig.setEntityResolver(javax.xml.stream.XMLResolver)
instead, if possible, since this just wraps passed in resolver.void
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.Methods inherited from class javax.xml.stream.XMLInputFactory
newFactory, newFactory, newInstance, newInstance
-
Field Details
-
MAX_SYMBOL_TABLE_SIZE
static final int MAX_SYMBOL_TABLE_SIZELet'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:
-
MAX_SYMBOL_TABLE_GENERATIONS
static final int MAX_SYMBOL_TABLE_GENERATIONSNumber 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:
-
mConfig
Current configurations for this factory -
mAllocator
-
mDTDCache
-
mRootSymbols
'Root' symbol table, used for creating actual symbol table instances, but never as is. -
mSymbols
Actual current 'parent' symbol table; concrete instances will be created from this instance usingmakeChild
method
-
-
Constructor Details
-
WstxInputFactory
public WstxInputFactory()
-
-
Method Details
-
addSymbol
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
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 interfaceReaderCreator
-
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.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 interfaceReaderCreator
-
addCachedDTD
- Specified by:
addCachedDTD
in interfaceReaderCreator
-
createFilteredReader
- Specified by:
createFilteredReader
in classXMLInputFactory
-
createFilteredReader
public XMLStreamReader createFilteredReader(XMLStreamReader reader, StreamFilter filter) throws XMLStreamException - Specified by:
createFilteredReader
in classXMLInputFactory
- Throws:
XMLStreamException
-
createXMLEventReader
- Specified by:
createXMLEventReader
in classXMLInputFactory
- Throws:
XMLStreamException
-
createXMLEventReader
- Specified by:
createXMLEventReader
in classXMLInputFactory
- Throws:
XMLStreamException
-
createXMLEventReader
- Specified by:
createXMLEventReader
in classXMLInputFactory
- Throws:
XMLStreamException
-
createXMLEventReader
- Specified by:
createXMLEventReader
in classXMLInputFactory
- Throws:
XMLStreamException
-
createXMLEventReader
public XMLEventReader createXMLEventReader(String systemId, InputStream in) throws XMLStreamException - Specified by:
createXMLEventReader
in classXMLInputFactory
- Throws:
XMLStreamException
-
createXMLEventReader
- Specified by:
createXMLEventReader
in classXMLInputFactory
- Throws:
XMLStreamException
-
createXMLEventReader
- Specified by:
createXMLEventReader
in classXMLInputFactory
- Throws:
XMLStreamException
-
createXMLStreamReader
- Specified by:
createXMLStreamReader
in classXMLInputFactory
- Throws:
XMLStreamException
-
createXMLStreamReader
- Specified by:
createXMLStreamReader
in classXMLInputFactory
- Throws:
XMLStreamException
-
createXMLStreamReader
- Specified by:
createXMLStreamReader
in classXMLInputFactory
- Throws:
XMLStreamException
-
createXMLStreamReader
- Specified by:
createXMLStreamReader
in classXMLInputFactory
- Throws:
XMLStreamException
-
createXMLStreamReader
public XMLStreamReader createXMLStreamReader(String systemId, InputStream in) throws XMLStreamException - Specified by:
createXMLStreamReader
in classXMLInputFactory
- Throws:
XMLStreamException
-
createXMLStreamReader
- Specified by:
createXMLStreamReader
in classXMLInputFactory
- Throws:
XMLStreamException
-
getProperty
- Specified by:
getProperty
in classXMLInputFactory
-
setProperty
- Specified by:
setProperty
in classXMLInputFactory
-
getEventAllocator
- Specified by:
getEventAllocator
in classXMLInputFactory
-
getXMLReporter
- Specified by:
getXMLReporter
in classXMLInputFactory
-
getXMLResolver
- Specified by:
getXMLResolver
in classXMLInputFactory
-
isPropertySupported
- Specified by:
isPropertySupported
in classXMLInputFactory
-
setEventAllocator
- Specified by:
setEventAllocator
in classXMLInputFactory
-
setXMLReporter
- Specified by:
setXMLReporter
in classXMLInputFactory
-
setXMLResolver
Note: it's preferable to use Wstx-specificReaderConfig.setEntityResolver(javax.xml.stream.XMLResolver)
instead, if possible, since this just wraps passed in resolver.- Specified by:
setXMLResolver
in classXMLInputFactory
-
createXMLEventReader
- Specified by:
createXMLEventReader
in classorg.codehaus.stax2.XMLInputFactory2
- Throws:
XMLStreamException
-
createXMLEventReader
- Specified by:
createXMLEventReader
in classorg.codehaus.stax2.XMLInputFactory2
- Throws:
XMLStreamException
-
createXMLStreamReader
- Specified by:
createXMLStreamReader
in classorg.codehaus.stax2.XMLInputFactory2
- Throws:
XMLStreamException
-
createXMLStreamReader
Convenience factory method that allows for parsing a document stored in the specified file.- Specified by:
createXMLStreamReader
in classorg.codehaus.stax2.XMLInputFactory2
- Throws:
XMLStreamException
-
configureForXmlConformance
public void configureForXmlConformance()- Specified by:
configureForXmlConformance
in classorg.codehaus.stax2.XMLInputFactory2
-
configureForConvenience
public void configureForConvenience()- Specified by:
configureForConvenience
in classorg.codehaus.stax2.XMLInputFactory2
-
configureForSpeed
public void configureForSpeed()- Specified by:
configureForSpeed
in classorg.codehaus.stax2.XMLInputFactory2
-
configureForLowMemUsage
public void configureForLowMemUsage()- Specified by:
configureForLowMemUsage
in classorg.codehaus.stax2.XMLInputFactory2
-
configureForRoundTripping
public void configureForRoundTripping()- Specified by:
configureForRoundTripping
in classorg.codehaus.stax2.XMLInputFactory2
-
getConfig
-
doCreateSR
private org.codehaus.stax2.XMLStreamReader2 doCreateSR(ReaderConfig cfg, SystemId systemId, InputBootstrapper bs, boolean forER, boolean autoCloseInput) throws 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 whenclose()
is called. Will be true for input sources that are automatically managed by stream reader (input streams created forURL
andFile
arguments, or when configuration settings indicate auto-closing is to be enabled (the default value is false as per Stax 1.0 specs).- Throws:
XMLStreamException
-
createSR
public org.codehaus.stax2.XMLStreamReader2 createSR(ReaderConfig cfg, String systemId, InputBootstrapper bs, boolean forER, boolean autoCloseInput) throws 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 readerforER
- 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 whenclose()
is called. Will be true for input sources that are automatically managed by stream reader (input streams created forURL
andFile
arguments, or when configuration settings indicate auto-closing is to be enabled (the default value is false as per Stax 1.0 specs).- Throws:
XMLStreamException
-
createSR
public org.codehaus.stax2.XMLStreamReader2 createSR(ReaderConfig cfg, SystemId systemId, InputBootstrapper bs, boolean forER, boolean autoCloseInput) throws XMLStreamException - Throws:
XMLStreamException
-
createSR
protected org.codehaus.stax2.XMLStreamReader2 createSR(SystemId systemId, InputStream in, String enc, boolean forER, boolean autoCloseInput) throws XMLStreamException - Throws:
XMLStreamException
-
createSR
protected org.codehaus.stax2.XMLStreamReader2 createSR(ReaderConfig cfg, URL src, boolean forER, boolean autoCloseInput) throws XMLStreamException - Throws:
XMLStreamException
-
createSR
private org.codehaus.stax2.XMLStreamReader2 createSR(ReaderConfig cfg, SystemId systemId, InputStream in, boolean forER, boolean autoCloseInput) throws XMLStreamException - Throws:
XMLStreamException
-
createSR
protected org.codehaus.stax2.XMLStreamReader2 createSR(SystemId systemId, Reader r, boolean forER, boolean autoCloseInput) throws XMLStreamException - Throws:
XMLStreamException
-
createSR
protected org.codehaus.stax2.XMLStreamReader2 createSR(File f, boolean forER, boolean autoCloseInput) throws XMLStreamException - Throws:
XMLStreamException
-
createSR
protected org.codehaus.stax2.XMLStreamReader2 createSR(Source src, boolean forER) throws 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:
XMLStreamException
-
createEventAllocator
-
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.
-