com.ctc.wstx.api
Class ReaderConfig

java.lang.Object
  extended bycom.ctc.wstx.api.ReaderConfig
All Implemented Interfaces:
InputConfigFlags

public final class ReaderConfig
extends java.lang.Object
implements InputConfigFlags

Simple configuration container class; passed by reader factory to reader instance created.

TODO:


Field Summary
static int DEFAULT_SHORTEST_TEXT_SEGMENT
          By default, let's require minimum of 64 chars to be delivered as shortest partial (piece of) text (CDATA, text) segment; same for both J2ME subset and full readers.
static int PROP_BASE_URL
           
static int PROP_CACHE_DTDS
           
static int PROP_COALESCE_TEXT
           
static int PROP_CUSTOM_INTERNAL_ENTITIES
           
static int PROP_DTD_RESOLVER
           
static int PROP_ENTITY_RESOLVER
           
static int PROP_EVENT_ALLOCATOR
           
static int PROP_INPUT_BUFFER_LENGTH
           
static int PROP_INTERN_NAMES
           
static int PROP_INTERN_NS_URIS
           
static int PROP_LAZY_PARSING
           
static int PROP_MIN_TEXT_SEGMENT
           
static int PROP_NAMESPACE_AWARE
           
static int PROP_NORMALIZE_ATTR_VALUES
           
static int PROP_NORMALIZE_LFS
           
static int PROP_PRESERVE_LOCATION
           
static int PROP_REPLACE_ENTITY_REFS
           
static int PROP_REPORT_ALL_TEXT_AS_CHARACTERS
           
static int PROP_REPORT_PROLOG_WS
           
static int PROP_SUPPORT_DTD
           
static int PROP_SUPPORT_DTDPP
           
static int PROP_SUPPORT_EXTERNAL_ENTITIES
           
static int PROP_TEXT_BUFFER_LENGTH
           
static int PROP_VALIDATE_AGAINST_DTD
           
static int PROP_WARNING_REPORTER
           
static int PROP_XML_RESOLVER
           
 
Fields inherited from interface com.ctc.wstx.cfg.InputConfigFlags
CFG_CACHE_DTDS, CFG_COALESCE_TEXT, CFG_INTERN_NS_URIS, CFG_LAZY_PARSING, CFG_NAMESPACE_AWARE, CFG_NORMALIZE_ATTR_VALUES, CFG_NORMALIZE_LFS, CFG_PRESERVE_LOCATION, CFG_REPLACE_ENTITY_REFS, CFG_REPORT_ALL_TEXT_AS_CHARACTERS, CFG_REPORT_PROLOG_WS, CFG_SUPPORT_DTD, CFG_SUPPORT_DTDPP, CFG_SUPPORT_EXTERNAL_ENTITIES, CFG_VALIDATE_AGAINST_DTD, CFG_VALIDATE_TEXT_CHARS, CONTENT_ALLOW_DTD_ANY, CONTENT_ALLOW_MIXED, CONTENT_ALLOW_NON_MIXED, CONTENT_ALLOW_NONE, CONTENT_ALLOW_UNDEFINED
 
Method Summary
 void clearConfigFlag(int flag)
           
 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 (linefeed conversions, attr value normalizations).
static ReaderConfig createFullDefaults(DTDReaderProxy dtdReader)
           
static ReaderConfig createJ2MEDefaults(DTDReaderProxy dtdReader)
           
 ReaderConfig createNonShared(SymbolTable sym)
           
 void doCacheDTDs(boolean state)
           
 void doCoalesceText(boolean state)
           
 void doInternNames(boolean state)
           
 void doInternNsURIs(boolean state)
           
 void doNormalizeAttrValues(boolean state)
           
 void doNormalizeLFs(boolean state)
           
 void doParseLazily(boolean state)
           
 void doPreserveLocation(boolean state)
           
 void doReplaceEntityRefs(boolean state)
           
 void doReportAllTextAsCharacters(boolean state)
           
 void doReportPrologWhitespace(boolean state)
           
 void doSupportDTDPP(boolean state)
           
 void doSupportDTDs(boolean state)
           
 void doSupportExternalEntities(boolean state)
           
 void doSupportNamespaces(boolean state)
           
 void doValidateWithDTD(boolean state)
           
 java.net.URL getBaseURL()
           
 int getConfigFlags()
           
 java.util.Map getCustomInternalEntities()
           
 int getDtdCacheSize()
          In future this property could/should be made configurable?
 DTDReaderProxy getDtdReader()
           
 javax.xml.stream.XMLResolver getDtdResolver()
           
 javax.xml.stream.XMLResolver getEntityResolver()
           
 int getInputBufferLength()
           
 java.lang.Object getProperty(int id)
           
 java.lang.Object getProperty(java.lang.String propName)
           
 int getPropertyId(java.lang.String id)
           
 int getShortestReportedTextSegment()
           
 SymbolTable getSymbols()
           
 int getTextBufferLength()
           
 javax.xml.stream.XMLReporter getXMLReporter()
           
 javax.xml.stream.XMLResolver getXMLResolver()
           
 boolean hasConfigFlags(int flags)
           
 boolean isPropertySupported(java.lang.String name)
           
 void setBaseURL(java.net.URL baseURL)
           
 void setConfigFlag(int flag)
           
 void setConfigFlags(int flags)
           
 void setCustomInternalEntities(java.util.Map m)
           
 void setDtdResolver(javax.xml.stream.XMLResolver r)
           
 void setEntityResolver(javax.xml.stream.XMLResolver r)
           
 void setInputBufferLength(int value)
           
 void setProperty(java.lang.String propName, int id, java.lang.Object value)
           
 void setProperty(java.lang.String propName, java.lang.Object value)
           
 void setShortestReportedTextSegment(int value)
           
 void setTextBufferLength(int value)
           
 void setXMLReporter(javax.xml.stream.XMLReporter r)
           
 void setXMLResolver(javax.xml.stream.XMLResolver r)
          Note: for better granularity, you should call setEntityResolver(javax.xml.stream.XMLResolver) and setDtdResolver(javax.xml.stream.XMLResolver) instead.
 boolean willCacheDTDs()
           
 boolean willCoalesceText()
           
 boolean willInternNames()
           
 boolean willInternNsURIs()
           
 boolean willNormalizeAttrValues()
           
 boolean willNormalizeLFs()
           
 boolean willParseLazily()
           
 boolean willPreserveLocation()
           
 boolean willReplaceEntityRefs()
           
 boolean willReportAllTextAsCharacters()
           
 boolean willReportPrologWhitespace()
           
 boolean willSupportDTDPP()
           
 boolean willSupportDTDs()
           
 boolean willSupportExternalEntities()
           
 boolean willSupportNamespaces()
           
 boolean willValidateWithDTD()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_COALESCE_TEXT

public static final int PROP_COALESCE_TEXT
See Also:
Constant Field Values

PROP_NAMESPACE_AWARE

public static final int PROP_NAMESPACE_AWARE
See Also:
Constant Field Values

PROP_REPLACE_ENTITY_REFS

public static final int PROP_REPLACE_ENTITY_REFS
See Also:
Constant Field Values

PROP_SUPPORT_EXTERNAL_ENTITIES

public static final int PROP_SUPPORT_EXTERNAL_ENTITIES
See Also:
Constant Field Values

PROP_VALIDATE_AGAINST_DTD

public static final int PROP_VALIDATE_AGAINST_DTD
See Also:
Constant Field Values

PROP_SUPPORT_DTD

public static final int PROP_SUPPORT_DTD
See Also:
Constant Field Values

PROP_EVENT_ALLOCATOR

public static final int PROP_EVENT_ALLOCATOR
See Also:
Constant Field Values

PROP_WARNING_REPORTER

public static final int PROP_WARNING_REPORTER
See Also:
Constant Field Values

PROP_XML_RESOLVER

public static final int PROP_XML_RESOLVER
See Also:
Constant Field Values

PROP_INTERN_NS_URIS

public static final int PROP_INTERN_NS_URIS
See Also:
Constant Field Values

PROP_INTERN_NAMES

public static final int PROP_INTERN_NAMES
See Also:
Constant Field Values

PROP_REPORT_ALL_TEXT_AS_CHARACTERS

public static final int PROP_REPORT_ALL_TEXT_AS_CHARACTERS
See Also:
Constant Field Values

PROP_REPORT_PROLOG_WS

public static final int PROP_REPORT_PROLOG_WS
See Also:
Constant Field Values

PROP_PRESERVE_LOCATION

public static final int PROP_PRESERVE_LOCATION
See Also:
Constant Field Values

PROP_NORMALIZE_LFS

public static final int PROP_NORMALIZE_LFS
See Also:
Constant Field Values

PROP_NORMALIZE_ATTR_VALUES

public static final int PROP_NORMALIZE_ATTR_VALUES
See Also:
Constant Field Values

PROP_CACHE_DTDS

public static final int PROP_CACHE_DTDS
See Also:
Constant Field Values

PROP_LAZY_PARSING

public static final int PROP_LAZY_PARSING
See Also:
Constant Field Values

PROP_SUPPORT_DTDPP

public static final int PROP_SUPPORT_DTDPP
See Also:
Constant Field Values

PROP_INPUT_BUFFER_LENGTH

public static final int PROP_INPUT_BUFFER_LENGTH
See Also:
Constant Field Values

PROP_TEXT_BUFFER_LENGTH

public static final int PROP_TEXT_BUFFER_LENGTH
See Also:
Constant Field Values

PROP_MIN_TEXT_SEGMENT

public static final int PROP_MIN_TEXT_SEGMENT
See Also:
Constant Field Values

PROP_CUSTOM_INTERNAL_ENTITIES

public static final int PROP_CUSTOM_INTERNAL_ENTITIES
See Also:
Constant Field Values

PROP_DTD_RESOLVER

public static final int PROP_DTD_RESOLVER
See Also:
Constant Field Values

PROP_ENTITY_RESOLVER

public static final int PROP_ENTITY_RESOLVER
See Also:
Constant Field Values

PROP_BASE_URL

public static final int PROP_BASE_URL
See Also:
Constant Field Values

DEFAULT_SHORTEST_TEXT_SEGMENT

public static final int DEFAULT_SHORTEST_TEXT_SEGMENT
By default, let's require minimum of 64 chars to be delivered as shortest partial (piece of) text (CDATA, text) segment; same for both J2ME subset and full readers. Prevents tiniest runts from getting passed

See Also:
Constant Field Values
Method Detail

createJ2MEDefaults

public static ReaderConfig createJ2MEDefaults(DTDReaderProxy dtdReader)

createFullDefaults

public static ReaderConfig createFullDefaults(DTDReaderProxy dtdReader)

createNonShared

public ReaderConfig createNonShared(SymbolTable sym)

getProperty

public java.lang.Object getProperty(java.lang.String propName)

isPropertySupported

public boolean isPropertySupported(java.lang.String name)

setProperty

public void setProperty(java.lang.String propName,
                        java.lang.Object value)

getSymbols

public SymbolTable getSymbols()

getDtdReader

public DTDReaderProxy getDtdReader()

getDtdCacheSize

public int getDtdCacheSize()
In future this property could/should be made configurable?


getConfigFlags

public int getConfigFlags()

hasConfigFlags

public boolean hasConfigFlags(int flags)

willCoalesceText

public boolean willCoalesceText()

willSupportNamespaces

public boolean willSupportNamespaces()

willReplaceEntityRefs

public boolean willReplaceEntityRefs()

willSupportExternalEntities

public boolean willSupportExternalEntities()

willSupportDTDs

public boolean willSupportDTDs()

willValidateWithDTD

public boolean willValidateWithDTD()

willNormalizeLFs

public boolean willNormalizeLFs()

willNormalizeAttrValues

public boolean willNormalizeAttrValues()

willInternNames

public boolean willInternNames()

willInternNsURIs

public boolean willInternNsURIs()

willReportAllTextAsCharacters

public boolean willReportAllTextAsCharacters()

willReportPrologWhitespace

public boolean willReportPrologWhitespace()

willCacheDTDs

public boolean willCacheDTDs()

willParseLazily

public boolean willParseLazily()

willPreserveLocation

public boolean willPreserveLocation()

willSupportDTDPP

public boolean willSupportDTDPP()

getInputBufferLength

public int getInputBufferLength()

getTextBufferLength

public int getTextBufferLength()

getShortestReportedTextSegment

public int getShortestReportedTextSegment()

getCustomInternalEntities

public java.util.Map getCustomInternalEntities()

getXMLReporter

public javax.xml.stream.XMLReporter getXMLReporter()

getXMLResolver

public javax.xml.stream.XMLResolver getXMLResolver()

getBaseURL

public java.net.URL getBaseURL()

getDtdResolver

public javax.xml.stream.XMLResolver getDtdResolver()

getEntityResolver

public javax.xml.stream.XMLResolver getEntityResolver()

setConfigFlags

public void setConfigFlags(int flags)

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)

doNormalizeLFs

public void doNormalizeLFs(boolean state)

doNormalizeAttrValues

public void doNormalizeAttrValues(boolean state)

doInternNames

public void doInternNames(boolean state)

doInternNsURIs

public void doInternNsURIs(boolean state)

doReportPrologWhitespace

public void doReportPrologWhitespace(boolean state)

doReportAllTextAsCharacters

public void doReportAllTextAsCharacters(boolean state)

doCacheDTDs

public void doCacheDTDs(boolean state)

doParseLazily

public void doParseLazily(boolean state)

doPreserveLocation

public void doPreserveLocation(boolean state)

doSupportDTDPP

public void doSupportDTDPP(boolean state)

setInputBufferLength

public void setInputBufferLength(int value)

setTextBufferLength

public void setTextBufferLength(int value)

setShortestReportedTextSegment

public void setShortestReportedTextSegment(int value)

setCustomInternalEntities

public void setCustomInternalEntities(java.util.Map m)

setXMLReporter

public void setXMLReporter(javax.xml.stream.XMLReporter r)

setXMLResolver

public void setXMLResolver(javax.xml.stream.XMLResolver r)
Note: for better granularity, you should call setEntityResolver(javax.xml.stream.XMLResolver) and setDtdResolver(javax.xml.stream.XMLResolver) instead.


setDtdResolver

public void setDtdResolver(javax.xml.stream.XMLResolver r)

setEntityResolver

public void setEntityResolver(javax.xml.stream.XMLResolver r)

setBaseURL

public void setBaseURL(java.net.URL baseURL)

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). See XMLInputFactory2.configureForXmlConformance() for required settings for standard StAX/StAX properties.

In addition to the standard settings, following Woodstox-specific settings are also done:

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. See XMLInputFactory2.configureForConvenience() for required settings for standard StAX/StAX properties.

In addition to the standard settings, following Woodstox-specific settings are also done:


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. See XMLInputFactory2.configureForSpeed() for required settings for standard StAX/StAX properties.

In addition to the standard settings, following Woodstox-specific settings are also done:

  • Disable P_NORMALIZE_LFS
  • Disable P_NORMALIZE_ATTR_VALUES
  • Enable P_CACHE_DTDS.
  • Enable P_LAZY_PARSING (can improve performance especially when skipping text segments)
  • 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_LENGTH a bit from default, to allow for longer consequtive read operations; also reduces cases where partial text segments are on input buffer boundaries.
  • Increase P_TEXT_BUFFER_LENGTH a bit from default; will reduce the likelihood of having to expand it during parsing.


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_SEGMENT to the (somewhat low) default value.
  • Reduces P_INPUT_BUFFER_LENGTH a bit from the default
  • Reduces P_TEXT_BUFFER_LENGTH a bit from the default


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:

  • Disable P_NORMALIZE_LFS
  • Disable P_NORMALIZE_ATTR_VALUES
  • Increases P_MIN_TEXT_SEGMENT to the maximum value so that all original text segment chunks are reported without segmentation (but without coalescing with adjacent CDATA segments)


getPropertyId

public int getPropertyId(java.lang.String id)

getProperty

public java.lang.Object getProperty(int id)

setProperty

public void setProperty(java.lang.String propName,
                        int id,
                        java.lang.Object value)