public class WstxInputFactory extends XMLInputFactory2 implements ReaderCreator, InputConfigFlags
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.
| Modifier and Type | Field and Description |
|---|---|
protected XMLEventAllocator |
mAllocator |
protected ReaderConfig |
mConfig
Current configurations for this factory
|
protected SimpleCache |
mDTDCache |
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_WHITESPACEALLOCATOR, IS_COALESCING, IS_NAMESPACE_AWARE, IS_REPLACING_ENTITY_REFERENCES, IS_SUPPORTING_EXTERNAL_ENTITIES, IS_VALIDATING, REPORTER, RESOLVER, SUPPORT_DTDCFG_AUTO_CLOSE_INPUT, CFG_CACHE_DTDS, CFG_CACHE_DTDS_BY_PUBLIC_ID, CFG_COALESCE_TEXT, CFG_INTERN_NAMES, CFG_INTERN_NS_URIS, 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_CHECKSXSP_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 and Description |
|---|
WstxInputFactory() |
| Modifier and Type | Method and Description |
|---|---|
void |
addCachedDTD(DTDId id,
DTDSubset extSubset) |
void |
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.
|
void |
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.
|
void |
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.
|
void |
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.
|
void |
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 |
createEventAllocator() |
XMLEventReader |
createFilteredReader(XMLEventReader reader,
EventFilter filter) |
XMLStreamReader |
createFilteredReader(XMLStreamReader reader,
StreamFilter filter) |
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).
|
protected XMLStreamReader2 |
createSR(File f,
boolean forER,
boolean autoCloseInput) |
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 XMLStreamReader2 |
createSR(ReaderConfig cfg,
URL src,
boolean forER,
boolean autoCloseInput) |
protected XMLStreamReader2 |
createSR(Source src,
boolean forER)
Another internal factory method, used when dealing with a generic
Source base type.
|
protected XMLStreamReader2 |
createSR(String systemId,
InputStream in,
String enc,
boolean forER,
boolean autoCloseInput) |
protected XMLStreamReader2 |
createSR(String systemId,
Reader r,
boolean forER,
boolean autoCloseInput) |
XMLEventReader2 |
createXMLEventReader(File f)
Convenience factory method that allows for parsing a document
stored in the specified file.
|
XMLEventReader |
createXMLEventReader(InputStream in) |
XMLEventReader |
createXMLEventReader(InputStream in,
String enc) |
XMLEventReader |
createXMLEventReader(Reader r) |
XMLEventReader |
createXMLEventReader(Source source) |
XMLEventReader |
createXMLEventReader(String systemId,
InputStream in) |
XMLEventReader |
createXMLEventReader(String systemId,
Reader r) |
XMLEventReader2 |
createXMLEventReader(URL src)
Factory method that allows for parsing a document accessible via
specified URL.
|
XMLEventReader |
createXMLEventReader(XMLStreamReader sr) |
XMLStreamReader2 |
createXMLStreamReader(File f)
Convenience factory method that allows for parsing a document
stored in the specified file.
|
XMLStreamReader |
createXMLStreamReader(InputStream in) |
XMLStreamReader |
createXMLStreamReader(InputStream in,
String enc) |
XMLStreamReader |
createXMLStreamReader(Reader r) |
XMLStreamReader |
createXMLStreamReader(Source src) |
XMLStreamReader |
createXMLStreamReader(String systemId,
InputStream in) |
XMLStreamReader |
createXMLStreamReader(String systemId,
Reader r) |
XMLStreamReader2 |
createXMLStreamReader(URL src)
Factory method that allows for parsing a document accessible via
specified URL.
|
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.
|
ReaderConfig |
getConfig() |
XMLEventAllocator |
getEventAllocator() |
Object |
getProperty(String name) |
XMLReporter |
getXMLReporter() |
XMLResolver |
getXMLResolver() |
boolean |
isPropertySupported(String name) |
void |
setEventAllocator(XMLEventAllocator allocator) |
void |
setProperty(String propName,
Object value) |
void |
setXMLReporter(XMLReporter r) |
void |
setXMLResolver(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. |
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.
|
newFactory, newFactory, newInstance, newInstanceprotected final ReaderConfig mConfig
protected XMLEventAllocator mAllocator
protected SimpleCache mDTDCache
public DTDSubset findCachedDTD(DTDId id)
findCachedDTD in interface ReaderCreatorpublic void updateSymbolTable(SymbolTable t)
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.
updateSymbolTable in interface ReaderCreatorpublic void addCachedDTD(DTDId id, DTDSubset extSubset)
addCachedDTD in interface ReaderCreatorpublic XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter)
createFilteredReader in class XMLInputFactorypublic XMLStreamReader createFilteredReader(XMLStreamReader reader, StreamFilter filter) throws XMLStreamException
createFilteredReader in class XMLInputFactoryXMLStreamExceptionpublic XMLEventReader createXMLEventReader(InputStream in) throws XMLStreamException
createXMLEventReader in class XMLInputFactoryXMLStreamExceptionpublic XMLEventReader createXMLEventReader(InputStream in, String enc) throws XMLStreamException
createXMLEventReader in class XMLInputFactoryXMLStreamExceptionpublic XMLEventReader createXMLEventReader(Reader r) throws XMLStreamException
createXMLEventReader in class XMLInputFactoryXMLStreamExceptionpublic XMLEventReader createXMLEventReader(Source source) throws XMLStreamException
createXMLEventReader in class XMLInputFactoryXMLStreamExceptionpublic XMLEventReader createXMLEventReader(String systemId, InputStream in) throws XMLStreamException
createXMLEventReader in class XMLInputFactoryXMLStreamExceptionpublic XMLEventReader createXMLEventReader(String systemId, Reader r) throws XMLStreamException
createXMLEventReader in class XMLInputFactoryXMLStreamExceptionpublic XMLEventReader createXMLEventReader(XMLStreamReader sr) throws XMLStreamException
createXMLEventReader in class XMLInputFactoryXMLStreamExceptionpublic XMLStreamReader createXMLStreamReader(InputStream in) throws XMLStreamException
createXMLStreamReader in class XMLInputFactoryXMLStreamExceptionpublic XMLStreamReader createXMLStreamReader(InputStream in, String enc) throws XMLStreamException
createXMLStreamReader in class XMLInputFactoryXMLStreamExceptionpublic XMLStreamReader createXMLStreamReader(Reader r) throws XMLStreamException
createXMLStreamReader in class XMLInputFactoryXMLStreamExceptionpublic XMLStreamReader createXMLStreamReader(Source src) throws XMLStreamException
createXMLStreamReader in class XMLInputFactoryXMLStreamExceptionpublic XMLStreamReader createXMLStreamReader(String systemId, InputStream in) throws XMLStreamException
createXMLStreamReader in class XMLInputFactoryXMLStreamExceptionpublic XMLStreamReader createXMLStreamReader(String systemId, Reader r) throws XMLStreamException
createXMLStreamReader in class XMLInputFactoryXMLStreamExceptionpublic Object getProperty(String name)
getProperty in class XMLInputFactorypublic void setProperty(String propName, Object value)
setProperty in class XMLInputFactorypublic XMLEventAllocator getEventAllocator()
getEventAllocator in class XMLInputFactorypublic XMLReporter getXMLReporter()
getXMLReporter in class XMLInputFactorypublic XMLResolver getXMLResolver()
getXMLResolver in class XMLInputFactorypublic boolean isPropertySupported(String name)
isPropertySupported in class XMLInputFactorypublic void setEventAllocator(XMLEventAllocator allocator)
setEventAllocator in class XMLInputFactorypublic void setXMLReporter(XMLReporter r)
setXMLReporter in class XMLInputFactorypublic void setXMLResolver(XMLResolver r)
ReaderConfig.setEntityResolver(javax.xml.stream.XMLResolver)
instead, if possible, since this just wraps passed in resolver.setXMLResolver in class XMLInputFactorypublic XMLEventReader2 createXMLEventReader(URL src) throws XMLStreamException
XMLInputFactory2createXMLEventReader in class XMLInputFactory2XMLStreamExceptionpublic XMLEventReader2 createXMLEventReader(File f) throws XMLStreamException
XMLInputFactory2createXMLEventReader in class XMLInputFactory2XMLStreamExceptionpublic XMLStreamReader2 createXMLStreamReader(URL src) throws XMLStreamException
XMLInputFactory2createXMLStreamReader in class XMLInputFactory2XMLStreamExceptionpublic XMLStreamReader2 createXMLStreamReader(File f) throws XMLStreamException
createXMLStreamReader in class XMLInputFactory2XMLStreamExceptionpublic void configureForXmlConformance()
XMLInputFactory2Regarding the default StAX property settings, implementations are suggested to do following:
SUPPORT_DTD property.
IS_NAMESPACE_AWARE
IS_REPLACING_ENTITY_REFERENCES
IS_SUPPORTING_EXTERNAL_ENTITIES
In addition, implementations should set implementation-dependant settings appropriately, to be as strict as possible with regards to XML specification mandated checks and transformations.
configureForXmlConformance in class XMLInputFactory2public void configureForConvenience()
XMLInputFactory2Regarding the default StAX property settings, implementations are suggested to do following:
IS_COALESCING (text coalescing)
IS_REPLACING_ENTITY_REFERENCES
P_REPORT_PROLOG_WHITESPACE (StAX2); so
that the application need not skip possible SPACE
(and COMMENT, PROCESSING_INSTRUCTION)
events.
P_REPORT_ALL_TEXT_AS_CHARACTERS (StAX2)
P_PRESERVE_LOCATION (StAX2)
In addition, implementations should set implementation-dependant settings appropriately as well.
configureForConvenience in class XMLInputFactory2public void configureForSpeed()
XMLInputFactory2Regarding the default StAX property settings, implementations are suggested to do following:
IS_COALESCING (text coalescing)
P_PRESERVE_LOCATION (StAX2)
P_REPORT_PROLOG_WHITESPACE (StAX2)
P_INTERN_NAMES (StAX2)
P_INTERN_NS_URIS (StAX2)
In addition, implementations should set implementation-dependant settings appropriately as well.
configureForSpeed in class XMLInputFactory2public void configureForLowMemUsage()
XMLInputFactory2Regarding the default StAX property settings, implementations are suggested to do following:
IS_COALECING (text coalescing, can force
longer internal result buffers to be used)
P_PRESERVE_LOCATION (StAX) to reduce
temporary memory usage.
In addition, implementations should set implementation-dependant settings appropriately so that the memory usage is minimized.
configureForLowMemUsage in class XMLInputFactory2public void configureForRoundTripping()
XMLInputFactory2Regarding the default StAX property settings, implementations are suggested to do following:
IS_COALESCING (to prevent CDATA and Text
segments from getting combined)
IS_REPLACING_ENTITY_REFERENCES to allow for
preserving explicitly declared general entity references (that is,
there is no way to preserve character entities, or pre-defined
entities like 'gt', 'lt', 'amp', 'apos' and 'quot').
P_REPORT_ALL_TEXT_AS_CHARACTERS (StAX2)
(so that CDATA sections are not reported as 'normal' text)
P_REPORT_PROLOG_WHITESPACE (StAX2)
In addition, implementations should set implementation-dependant settings appropriately as well.
configureForRoundTripping in class XMLInputFactory2public ReaderConfig getConfig()
public XMLStreamReader2 createSR(ReaderConfig cfg, String systemId, InputBootstrapper bs, boolean forER, boolean autoCloseInput) throws XMLStreamException
Note: defined as public method because it needs to be called by SAX implementation.
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 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).XMLStreamExceptionprotected XMLStreamReader2 createSR(String systemId, InputStream in, String enc, boolean forER, boolean autoCloseInput) throws XMLStreamException
XMLStreamExceptionprotected XMLStreamReader2 createSR(ReaderConfig cfg, URL src, boolean forER, boolean autoCloseInput) throws XMLStreamException
XMLStreamExceptionprotected XMLStreamReader2 createSR(String systemId, Reader r, boolean forER, boolean autoCloseInput) throws XMLStreamException
XMLStreamExceptionprotected XMLStreamReader2 createSR(File f, boolean forER, boolean autoCloseInput) throws XMLStreamException
XMLStreamExceptionprotected XMLStreamReader2 createSR(Source src, boolean forER) throws XMLStreamException
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)XMLStreamExceptionprotected XMLEventAllocator createEventAllocator()
public ReaderConfig createPrivateConfig()
Note: only public so that other woodstox components outside of this package can access it.