Class ReaderConfig
- All Implemented Interfaces:
InputConfigFlags,org.codehaus.stax2.XMLStreamProperties
In addition to its main task as a configuration container, this class also acts as a wrapper around simple buffer recycling functionality. The reason is that while conceptually this is a separate concern, there are enough commonalities with the life-cycle of this object to make this a very convenience place to add that functionality... (that is: conceptually this is not right, but from pragmatic viewpoint it just makes sense)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intprotected static final Stringprotected static final StringThis is "major.minor" version used for purposes of determining the feature set.protected booleanWhether to allow surrogate pairs as entities (2 code-points as one target character).protected URLBase URL to use as the resolution context for relative entity referencesprotected intBitset that indicates explicit changes tomConfigFlagsthrough calls; empty bit means that the corresponding property has its default value, set bit that an explicit call has been made.protected intBitset that contains state of on/off properties; initialized to defaults, but can be set/cleared.protected intprotected final booleanprotected intprotected intprotected longprotected intprotected intprotected longprotected intprotected longprotected intprotected intprotected intprotected WstxInputProperties.ParsingModeParsing mode can be changed from the default xml compliant behavior to one of alternate modes (fragment processing, multiple document processing).protected booleanAs per [WSTX-277], can specify whether prefix for the "default namespace" is return as null (true) or empty String (false)protected final SymbolTableprotected booleanThis boolean flag is set if the input document requires xml 1.1 (or above) compliant processing: default is xml 1.0 compliant.static final intFields 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_CHECKSFields 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 -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean_hasConfigFlag(int flag) protected boolean_hasExplicitConfigFlag(int flag) Method similar to_hasConfigFlag(int), but that will only return true if in addition to being set, flag has been explicitly modified (i.e. setProperty has been called to modify it)byte[]allocFullBBuffer(int minSize) char[]allocFullCBuffer(int minSize) char[]allocMediumCBuffer(int minSize) char[]allocSmallCBuffer(int minSize) booleanvoidclearConfigFlag(int flag) voidMethod 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.voidMethod to call to minimize the memory usage of the stream/event reader; both regarding Objects created, and the temporary memory usage during parsing.voidMethod 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.voidMethod 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.voidMethod to call to make Reader created conform as closely to XML standard as possible, doing all checks and transformations mandated (linefeed conversions, attr value normalizations).static ReaderConfigstatic ReaderConfigvoiddoAllowSurrogatePairEntities(boolean state) voiddoAllowXml11EscapedCharsInXml10(boolean state) voiddoAutoCloseInput(boolean state) voiddoCacheDTDs(boolean state) voiddoCacheDTDsByPublicId(boolean state) voiddoCoalesceText(boolean state) booleanbooleanvoiddoInternNames(boolean state) voiddoInternNsURIs(boolean state) voiddoNormalizeLFs(boolean state) voiddoParseLazily(boolean state) voiddoPreserveLocation(boolean state) voiddoProcessSecurely(boolean value) Method called when {code XMLConstants.FEATURE_SECURE_PROCESSING} is being enabled or disabled.voiddoReplaceEntityRefs(boolean state) voiddoReportCData(boolean state) voiddoReportPrologWhitespace(boolean state) voiddoSupportDTDPP(boolean state) voiddoSupportDTDs(boolean state) voiddoSupportExternalEntities(boolean state) voiddoSupportNamespaces(boolean state) voiddoTreatCharRefsAsEnts(boolean state) voiddoValidateWithDTD(boolean state) voiddoXmlIdTyping(boolean state) voiddoXmlIdUniqChecks(boolean state) voidenableXml11(boolean state) Method called to enable or disable 1.1 compliant processing; if disabled, defaults to xml 1.0 compliant processing.protected intfindPropertyId(String propName) protected intfindStdPropertyId(String propName) voidfreeFullBBuffer(byte[] buffer) voidfreeFullCBuffer(char[] buffer) voidfreeMediumCBuffer(char[] buffer) voidfreeSmallCBuffer(char[] buffer) intintIn future this property could/should be made configurable?org.codehaus.stax2.validation.DTDValidationSchemastatic StringMethod used to figure out the official implementation name for input/output/validation factories.static StringMethod used to figure out the official implementation version for input/output/validation factories.intintintlongintintlongintlongintlonggetProperty(int id) getProperty(String propName) intprotected ObjectgetStdProperty(int id) booleanSpecial accessor to use to verify whether name interning has explicitly been enabled; true if call was been made to set it to true; false otherwise (default, or set to false)booleanbooleanbooleanbooleanChecks if the user explicitly set coalescing to false.booleanisPropertySupported(String propName) booleanisXml11()protected voidreportUnknownProperty(String propName) voidUnlike name suggests there is also some limited state information associated with the config object.booleanfinal ObjectsafeGetProperty(String propName) voidsetBaseURL(URL baseURL) voidsetConfigFlag(int flag) voidvoidvoidsetDTDOverride(org.codehaus.stax2.validation.DTDValidationSchema schema) voidvoidvoidsetInputBufferLength(int value) voidvoidsetMaxAttributeSize(int value) voidsetMaxAttributesPerElement(int value) voidsetMaxCharacters(long value) voidsetMaxChildrenPerElement(int value) voidsetMaxDtdDepth(int value) voidsetMaxElementCount(long value) voidsetMaxElementDepth(int value) voidsetMaxEntityCount(long value) voidsetMaxEntityDepth(int value) voidsetMaxTextLength(int value) booleansetProperty(String propName, int id, Object value) booleansetProperty(String propName, Object value) voidsetShortestReportedTextSegment(int value) protected booleansetStdProperty(String propName, int id, Object value) voidvoidvoidNote: for better granularity, you should callsetEntityResolver(javax.xml.stream.XMLResolver)andsetDtdResolver(javax.xml.stream.XMLResolver)instead.booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanboolean
-
Field Details
-
DEFAULT_MAX_ATTRIBUTES_PER_ELEMENT
public static final int DEFAULT_MAX_ATTRIBUTES_PER_ELEMENT- See Also:
-
DEFAULT_MAX_ATTRIBUTE_LENGTH
public static final int DEFAULT_MAX_ATTRIBUTE_LENGTH- See Also:
-
DEFAULT_MAX_ELEMENT_DEPTH
public static final int DEFAULT_MAX_ELEMENT_DEPTH- See Also:
-
DEFAULT_MAX_ENTITY_DEPTH
public static final int DEFAULT_MAX_ENTITY_DEPTH- See Also:
-
DEFAULT_MAX_ENTITY_COUNT
public static final int DEFAULT_MAX_ENTITY_COUNT- See Also:
-
DEFAULT_MAX_DTD_DEPTH
public static final int DEFAULT_MAX_DTD_DEPTH- See Also:
-
PROP_EVENT_ALLOCATOR
public static final int PROP_EVENT_ALLOCATOR- See Also:
-
mIsJ2MESubset
protected final boolean mIsJ2MESubset -
mSymbols
-
mConfigFlags
protected int mConfigFlagsBitset that contains state of on/off properties; initialized to defaults, but can be set/cleared. -
mConfigFlagMods
protected int mConfigFlagModsBitset that indicates explicit changes tomConfigFlagsthrough calls; empty bit means that the corresponding property has its default value, set bit that an explicit call has been made. -
mInputBufferLen
protected int mInputBufferLen -
mMinTextSegmentLen
protected int mMinTextSegmentLen -
mMaxAttributesPerElement
protected int mMaxAttributesPerElement -
mMaxAttributeSize
protected int mMaxAttributeSize -
mMaxChildrenPerElement
protected int mMaxChildrenPerElement -
mMaxElementDepth
protected int mMaxElementDepth -
mMaxElementCount
protected long mMaxElementCount -
mMaxCharacters
protected long mMaxCharacters -
mMaxTextLength
protected int mMaxTextLength -
mMaxEntityDepth
protected int mMaxEntityDepth -
mMaxEntityCount
protected long mMaxEntityCount -
mMaxDtdDepth
protected int mMaxDtdDepth -
mBaseURL
Base URL to use as the resolution context for relative entity references -
mAllowSurrogatePairEntities
protected boolean mAllowSurrogatePairEntitiesWhether to allow surrogate pairs as entities (2 code-points as one target character).- Since:
- 6.6
-
mParsingMode
Parsing mode can be changed from the default xml compliant behavior to one of alternate modes (fragment processing, multiple document processing). -
mXml11
protected boolean mXml11This boolean flag is set if the input document requires xml 1.1 (or above) compliant processing: default is xml 1.0 compliant. Note that unlike most other properties, this does not come from configuration settings, but from processed document itself. -
IMPL_NAME
- See Also:
-
IMPL_VERSION
This is "major.minor" version used for purposes of determining the feature set. Patch level is not included, since those should not affect API or feature set. Using applications should be prepared to take additional levels, however, just not depend on those being available.- See Also:
-
mReturnNullForDefaultNamespace
protected boolean mReturnNullForDefaultNamespaceAs per [WSTX-277], can specify whether prefix for the "default namespace" is return as null (true) or empty String (false)
-
-
Method Details
-
createJ2MEDefaults
-
createFullDefaults
-
resetState
public void resetState()Unlike name suggests there is also some limited state information associated with the config object. If these objects are reused, that state needs to be reset between reuses, to avoid carrying over incorrect state. -
findPropertyId
- Returns:
- Internal enumerated int matching the String name of the property, if one found: -1 to indicate no match was found.
-
getSymbols
-
getDtdCacheSize
public int getDtdCacheSize()In future this property could/should be made configurable? -
getConfigFlags
public int getConfigFlags() -
willCoalesceText
public boolean willCoalesceText() -
willSupportNamespaces
public boolean willSupportNamespaces() -
willReplaceEntityRefs
public boolean willReplaceEntityRefs() -
willSupportExternalEntities
public boolean willSupportExternalEntities() -
willSupportDTDs
public boolean willSupportDTDs() -
willValidateWithDTD
public boolean willValidateWithDTD() -
willReportCData
public boolean willReportCData() -
willParseLazily
public boolean willParseLazily() -
willInternNames
public boolean willInternNames() -
willInternNsURIs
public boolean willInternNsURIs() -
willPreserveLocation
public boolean willPreserveLocation() -
willAutoCloseInput
public boolean willAutoCloseInput() -
willProcessSecurely
public boolean willProcessSecurely() -
willReportPrologWhitespace
public boolean willReportPrologWhitespace() -
willCacheDTDs
public boolean willCacheDTDs() -
willCacheDTDsByPublicId
public boolean willCacheDTDsByPublicId() -
willDoXmlIdTyping
public boolean willDoXmlIdTyping() -
willDoXmlIdUniqChecks
public boolean willDoXmlIdUniqChecks() -
willSupportDTDPP
public boolean willSupportDTDPP() -
willNormalizeLFs
public boolean willNormalizeLFs() -
willTreatCharRefsAsEnts
public boolean willTreatCharRefsAsEnts() -
willAllowXml11EscapedCharsInXml10
public boolean willAllowXml11EscapedCharsInXml10() -
getInputBufferLength
public int getInputBufferLength() -
getShortestReportedTextSegment
public int getShortestReportedTextSegment() -
getMaxAttributesPerElement
public int getMaxAttributesPerElement() -
getMaxAttributeSize
public int getMaxAttributeSize() -
getMaxChildrenPerElement
public int getMaxChildrenPerElement() -
getMaxElementDepth
public int getMaxElementDepth() -
getMaxElementCount
public long getMaxElementCount() -
getMaxEntityDepth
public int getMaxEntityDepth() -
getMaxEntityCount
public long getMaxEntityCount() -
getMaxDtdDepth
public int getMaxDtdDepth() -
getMaxCharacters
public long getMaxCharacters() -
getMaxTextLength
public long getMaxTextLength() -
getCustomInternalEntities
-
findCustomInternalEntity
-
getXMLReporter
-
getXMLResolver
-
getDtdResolver
-
getEntityResolver
-
getUndeclaredEntityResolver
-
getBaseURL
-
allowsSurrogatePairEntities
public boolean allowsSurrogatePairEntities() -
getInputParsingMode
-
inputParsingModeDocuments
public boolean inputParsingModeDocuments() -
inputParsingModeFragment
public boolean inputParsingModeFragment() -
isXml11
public boolean isXml11()- Returns:
- True if the input well-formedness and validation checks should be done according to xml 1.1 specification; false if xml 1.0 specification.
-
getDTDEventListener
-
getDTDOverride
public org.codehaus.stax2.validation.DTDValidationSchema getDTDOverride() -
hasInternNamesBeenEnabled
public boolean hasInternNamesBeenEnabled()Special accessor to use to verify whether name interning has explicitly been enabled; true if call was been made to set it to true; false otherwise (default, or set to false) -
hasInternNsURIsBeenEnabled
public boolean hasInternNsURIsBeenEnabled() -
isCoalescingExplicitlyDisabled
public boolean isCoalescingExplicitlyDisabled()Checks if the user explicitly set coalescing to false. (That is if coalescing is disabled only because that is the default value, this method will return false.)- Returns:
- true, if the user explicitly disabled coalescing, else false
-
setConfigFlag
public void setConfigFlag(int flag) -
clearConfigFlag
public void clearConfigFlag(int flag) -
doCoalesceText
public void doCoalesceText(boolean state) -
doSupportNamespaces
public void doSupportNamespaces(boolean state) -
doReplaceEntityRefs
public void doReplaceEntityRefs(boolean state) -
doSupportExternalEntities
public void doSupportExternalEntities(boolean state) -
doSupportDTDs
public void doSupportDTDs(boolean state) -
doValidateWithDTD
public void doValidateWithDTD(boolean state) -
doProcessSecurely
public void doProcessSecurely(boolean value) Method called when {code XMLConstants.FEATURE_SECURE_PROCESSING} is being enabled or disabled.Note that disabling (passing {code false} as argument) does not actually change any settings.
Calls made when
trueis passed (that is, secure processing enabled):doSupportExternalEntities(false)
- Since:
- 5.3
-
doInternNames
public void doInternNames(boolean state) -
doInternNsURIs
public void doInternNsURIs(boolean state) -
doReportPrologWhitespace
public void doReportPrologWhitespace(boolean state) -
doReportCData
public void doReportCData(boolean state) -
doCacheDTDs
public void doCacheDTDs(boolean state) -
doCacheDTDsByPublicId
public void doCacheDTDsByPublicId(boolean state) -
doParseLazily
public void doParseLazily(boolean state) -
doXmlIdTyping
public void doXmlIdTyping(boolean state) -
doXmlIdUniqChecks
public void doXmlIdUniqChecks(boolean state) -
doPreserveLocation
public void doPreserveLocation(boolean state) -
doAutoCloseInput
public void doAutoCloseInput(boolean state) -
doSupportDTDPP
public void doSupportDTDPP(boolean state) -
doTreatCharRefsAsEnts
public void doTreatCharRefsAsEnts(boolean state) -
doAllowXml11EscapedCharsInXml10
public void doAllowXml11EscapedCharsInXml10(boolean state) -
doNormalizeLFs
public void doNormalizeLFs(boolean state) -
setInputBufferLength
public void setInputBufferLength(int value) -
setShortestReportedTextSegment
public void setShortestReportedTextSegment(int value) -
setMaxAttributesPerElement
public void setMaxAttributesPerElement(int value) -
setMaxAttributeSize
public void setMaxAttributeSize(int value) -
setMaxChildrenPerElement
public void setMaxChildrenPerElement(int value) -
setMaxElementDepth
public void setMaxElementDepth(int value) -
setMaxElementCount
public void setMaxElementCount(long value) -
setMaxCharacters
public void setMaxCharacters(long value) -
setMaxTextLength
public void setMaxTextLength(int value) -
setMaxEntityDepth
public void setMaxEntityDepth(int value) -
setMaxEntityCount
public void setMaxEntityCount(long value) -
setMaxDtdDepth
public void setMaxDtdDepth(int value) -
setCustomInternalEntities
-
setXMLReporter
-
setXMLResolver
Note: for better granularity, you should callsetEntityResolver(javax.xml.stream.XMLResolver)andsetDtdResolver(javax.xml.stream.XMLResolver)instead. -
setDtdResolver
-
setEntityResolver
-
setUndeclaredEntityResolver
-
setBaseURL
-
doAllowSurrogatePairEntities
public void doAllowSurrogatePairEntities(boolean state) -
setInputParsingMode
-
enableXml11
public void enableXml11(boolean state) Method called to enable or disable 1.1 compliant processing; if disabled, defaults to xml 1.0 compliant processing. -
setDTDEventListener
-
setDTDOverride
public void setDTDOverride(org.codehaus.stax2.validation.DTDValidationSchema schema) -
configureForXmlConformance
public void configureForXmlConformance()Method to call to make Reader created conform as closely to XML standard as possible, doing all checks and transformations mandated (linefeed conversions, attr value normalizations). SeeXMLInputFactory2.configureForXmlConformance()for required settings for standard StAX/StAX properties.In addition to the standard settings, following Woodstox-specific settings are also done:
- None
Notes: Does NOT change 'performance' settings (buffer sizes, DTD caching, coalescing, interning, accurate location info).
-
configureForConvenience
public 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. This may incur some slight performance penalties, but should not affect XML conformance. SeeXMLInputFactory2.configureForConvenience()for required settings for standard StAX/StAX properties.In addition to the standard settings, following Woodstox-specific settings are also done:
- Disable
XMLStreamFactory2.P_LAZY_PARSING(to allow for synchronous error notification by forcing full XML events to be completely parsed when reader'snext()is called)
- Disable
-
configureForSpeed
public 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. SeeXMLInputFactory2.configureForSpeed()for required settings for standard StAX/StAX properties.In addition to the standard settings, following Woodstox-specific settings are also done:
- Enable
P_CACHE_DTDS. - Enable
XMLStremaFactory2.P_LAZY_PARSING(can improve performance especially when skipping text segments) - Disable Xml:id uniqueness checks (and leave typing as is)
- Set lowish value for
P_MIN_TEXT_SEGMENT, to allow reader to optimize segment length it uses (and possibly avoids one copy operation in the process) - Increase
P_INPUT_BUFFER_LENGTHa bit from default, to allow for longer consequtive read operations; also reduces cases where partial text segments are on input buffer boundaries.
- Enable
-
configureForLowMemUsage
public 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. This generally incurs some performance penalties, due to using smaller input buffers.See
XMLInputFactory2.configureForLowMemUsage()for required settings for standard StAX/StAX properties.In addition to the standard settings, following Woodstox-specific settings are also done:
- Disable
P_CACHE_DTDS - Enable
P_PARSE_LAZILY - Resets
P_MIN_TEXT_SEGMENTto the (somewhat low) default value. - Reduces
P_INPUT_BUFFER_LENGTHa bit from the default
- Disable
-
configureForRoundTripping
public 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.See
XMLInputFactory2.configureForLowMemUsage()for required settings for standard StAX/StAX properties.In addition to the standard settings, following Woodstox-specific settings are also done:
- Increases
P_MIN_TEXT_SEGMENTto the maximum value so that all original text segment chunks are reported without segmentation (but without coalescing with adjacent CDATA segments) - Sets
P_TREAT_CHAR_REFS_AS_ENTSto true, so the all the original character references are reported with their position, original text, and the replacement text.
- Increases
-
allocSmallCBuffer
public char[] allocSmallCBuffer(int minSize) -
freeSmallCBuffer
public void freeSmallCBuffer(char[] buffer) -
allocMediumCBuffer
public char[] allocMediumCBuffer(int minSize) -
freeMediumCBuffer
public void freeMediumCBuffer(char[] buffer) -
allocFullCBuffer
public char[] allocFullCBuffer(int minSize) -
freeFullCBuffer
public void freeFullCBuffer(char[] buffer) -
allocFullBBuffer
public byte[] allocFullBBuffer(int minSize) -
freeFullBBuffer
public void freeFullBBuffer(byte[] buffer) -
getProperty
-
setProperty
-
_hasConfigFlag
protected boolean _hasConfigFlag(int flag) -
_hasExplicitConfigFlag
protected boolean _hasExplicitConfigFlag(int flag) Method similar to_hasConfigFlag(int), but that will only return true if in addition to being set, flag has been explicitly modified (i.e. setProperty has been called to modify it) -
getProperty
-
isPropertySupported
-
setProperty
- Returns:
- True, if the specified property was successfully set to specified value; false if its value was not changed
-
reportUnknownProperty
-
safeGetProperty
-
getImplName
Method used to figure out the official implementation name for input/output/validation factories. -
getImplVersion
Method used to figure out the official implementation version for input/output/validation factories. -
doesSupportXml11
public boolean doesSupportXml11() -
doesSupportXmlId
public boolean doesSupportXmlId() -
returnNullForDefaultNamespace
public boolean returnNullForDefaultNamespace() -
findStdPropertyId
-
setStdProperty
- Parameters:
propName- Name of standard property to setid- Internal id matching the namevalue- Value to set the standard property to
-
getStdProperty
-