Class ReaderConfig


  • public final class ReaderConfig
    extends CommonConfig
    This is the shared configuration object passed by the factory to reader, and by reader to whoever needs it (scanners at least).
    • Field Detail

      • DEFAULT_SMALL_BUFFER_LEN

        public static final int DEFAULT_SMALL_BUFFER_LEN
        See Also:
        Constant Field Values
      • DEFAULT_CHAR_BUFFER_LEN

        public static final int DEFAULT_CHAR_BUFFER_LEN
        See Also:
        Constant Field Values
      • DEFAULT_FLAGS

        static final int DEFAULT_FLAGS
        These are the default settigs for XMLInputFactory.
        See Also:
        Constant Field Values
      • sProperties

        private static final java.util.HashMap<java.lang.String,​java.lang.Object> sProperties
      • mEncCtxt

        private final ReaderConfig.EncodingContext mEncCtxt
        A single encoding context instance is shared between all ReaderConfig instances created for readers by an input factory. It is used for sharing symbol tables.
      • mCanonicalizer

        private final UriCanonicalizer mCanonicalizer
        For efficient access by qualified name, as well as uniqueness checks, namespace URIs need to be canonicalized.
      • mPublicId

        private final java.lang.String mPublicId
      • mSystemId

        private final java.lang.String mSystemId
      • mExtEncoding

        private final java.lang.String mExtEncoding
        Encoding passed in as external information, possibly from source from which xml content was gained from (for example, as an HTTP header, or file metadata).
      • mActualEncoding

        private java.lang.String mActualEncoding
        Name of the actual encoding that input was found to be in (if any -- can't be determined if a Reader was passed in).
      • mXmlDeclVersion

        private java.lang.String mXmlDeclVersion
      • mXmlDeclEncoding

        private java.lang.String mXmlDeclEncoding
      • mXmlDeclStandalone

        private int mXmlDeclStandalone
      • mReporter

        private javax.xml.stream.XMLReporter mReporter
      • mResolver

        private javax.xml.stream.XMLResolver mResolver
      • _recyclerRef

        static final java.lang.ThreadLocal<java.lang.ref.SoftReference<BufferRecycler>> _recyclerRef
        This ThreadLocal contains a SoftRerefence to a BufferRecycler used to provide a low-cost buffer recycling between Reader instances.
      • _currRecycler

        protected BufferRecycler _currRecycler
        This is the actually container of the recyclable buffers. It is obtained via ThreadLocal/SoftReference combination, if one exists, when Config instance is created. If one does not exist, it will created first time a buffer is returned.
    • Constructor Detail

      • ReaderConfig

        private ReaderConfig​(java.lang.String publicId,
                             java.lang.String systemId,
                             java.lang.String extEnc,
                             ReaderConfig.EncodingContext encCtxt,
                             int flags,
                             int flagMods,
                             javax.xml.stream.XMLReporter rep,
                             javax.xml.stream.XMLResolver res,
                             UriCanonicalizer canonicalizer)
      • ReaderConfig

        public ReaderConfig()
    • Method Detail

      • setActualEncoding

        public void setActualEncoding​(java.lang.String actualEnc)
      • setXmlDeclInfo

        public void setXmlDeclInfo​(int version,
                                   java.lang.String xmlDeclEnc,
                                   java.lang.String standalone)
      • setXmlVersion

        public final void setXmlVersion​(java.lang.String version)
      • setXmlEncoding

        public final void setXmlEncoding​(java.lang.String enc)
      • setXmlStandalone

        public final void setXmlStandalone​(java.lang.Boolean b)
      • setXMLReporter

        public void setXMLReporter​(javax.xml.stream.XMLReporter r)
      • setXMLResolver

        public void setXMLResolver​(javax.xml.stream.XMLResolver r)
      • doCoalesceText

        public void doCoalesceText​(boolean state)
      • doAutoCloseInput

        public void doAutoCloseInput​(boolean state)
      • doPreserveLocation

        public void doPreserveLocation​(boolean state)
      • doParseLazily

        public void doParseLazily​(boolean state)
      • doReportCData

        public void doReportCData​(boolean state)
      • createNonShared

        public ReaderConfig createNonShared​(java.lang.String publicId,
                                            java.lang.String systemId,
                                            java.lang.String extEnc)
      • getExternalEncoding

        public java.lang.String getExternalEncoding()
        Description copied from class: CommonConfig
        This method returns name of encoding that has been passed explicitly to the reader or writer, from outside. An example is that HTTP server may pass encoding as declared in HTTP headers. This should either be null (if none passed), or the same as actual encoding (which is determined from physical stream contents [for readers], or from encoder properties / configuration [for writers]
        Specified by:
        getExternalEncoding in class CommonConfig
        Returns:
        Encoding that has been passed externally by the application
      • getActualEncoding

        public java.lang.String getActualEncoding()
        Specified by:
        getActualEncoding in class CommonConfig
        Returns:
        Actual encoding in use, as determined by the processor.
      • isXml11

        public boolean isXml11()
        Specified by:
        isXml11 in class CommonConfig
        Returns:
        True, if the processing will be done according to Xml 1.1 rules; false if according to xml 1.0
      • findPropertyId

        protected int findPropertyId​(java.lang.String propName)
      • getProperty

        public final java.lang.Object getProperty​(java.lang.String name,
                                                  boolean isMandatory)
        Overrides:
        getProperty in class CommonConfig
        isMandatory - If true, unrecognized property should result in IllegalArgumentException
      • setProperty

        public boolean setProperty​(java.lang.String name,
                                   java.lang.Object value)
        Overrides:
        setProperty in class CommonConfig
        Returns:
        True, if the specified property was succesfully set to specified value; false if its value was not changed
      • getXMLReporter

        public javax.xml.stream.XMLReporter getXMLReporter()
      • getXMLResolver

        public javax.xml.stream.XMLResolver getXMLResolver()
      • willExpandEntities

        public boolean willExpandEntities()
      • willCoalesceText

        public boolean willCoalesceText()
      • willSupportNamespaces

        public boolean willSupportNamespaces()
      • willParseLazily

        public boolean willParseLazily()
      • willInternNames

        public boolean willInternNames()
      • willInternNsURIs

        public boolean willInternNsURIs()
      • willReportCData

        public boolean willReportCData()
      • willPreserveLocation

        public boolean willPreserveLocation()
      • willAutoCloseInput

        public boolean willAutoCloseInput()
      • hasInternNamesBeenEnabled

        public boolean hasInternNamesBeenEnabled()
      • hasInternNsURIsBeenEnabled

        public boolean hasInternNsURIsBeenEnabled()
      • getPublicId

        public java.lang.String getPublicId()
      • getSystemId

        public java.lang.String getSystemId()
      • getXmlDeclVersion

        public java.lang.String getXmlDeclVersion()
      • getXmlDeclEncoding

        public java.lang.String getXmlDeclEncoding()
      • getXmlDeclStandalone

        public int getXmlDeclStandalone()
      • 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/StAX2 properties.

        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/StAX2 properties.
      • 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/StAX2 properties.

      • 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/StAX2 properties.

      • 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/StAX2 properties.

      • canonicalizeURI

        public java.lang.String canonicalizeURI​(char[] buf,
                                                int uriLen)
      • 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)
      • setIllegalCharHandler

        public void setIllegalCharHandler​(IllegalCharHandler illegalCharHandler)