Class WriterConfig

  • All Implemented Interfaces:
    OutputConfigFlags, org.codehaus.stax2.XMLStreamProperties

    public final class WriterConfig
    extends CommonConfig
    implements OutputConfigFlags
    Simple configuration container class; passed by writer factory to writer instance created.
    • Field Detail

      • DEFAULT_AUTOMATIC_NS_PREFIX

        protected static final java.lang.String DEFAULT_AUTOMATIC_NS_PREFIX
        See Also:
        Constant Field Values
      • PROP_AUTOMATIC_EMPTY_ELEMENTS

        static final int PROP_AUTOMATIC_EMPTY_ELEMENTS
        See Also:
        Constant Field Values
      • PROP_USE_DOUBLE_QUOTES_IN_XML_DECL

        static final int PROP_USE_DOUBLE_QUOTES_IN_XML_DECL
        See Also:
        Constant Field Values
      • PROP_ADD_SPACE_AFTER_EMPTY_ELEM

        static final int PROP_ADD_SPACE_AFTER_EMPTY_ELEM
        See Also:
        Constant Field Values
      • PROP_AUTOMATIC_END_ELEMENTS

        static final int PROP_AUTOMATIC_END_ELEMENTS
        See Also:
        Constant Field Values
      • PROP_OUTPUT_INVALID_CHAR_HANDLER

        static final int PROP_OUTPUT_INVALID_CHAR_HANDLER
        See Also:
        Constant Field Values
      • PROP_OUTPUT_EMPTY_ELEMENT_HANDLER

        static final int PROP_OUTPUT_EMPTY_ELEMENT_HANDLER
        See Also:
        Constant Field Values
      • DEFAULT_USE_DOUBLE_QUOTES_IN_XML_DECL

        static final boolean DEFAULT_USE_DOUBLE_QUOTES_IN_XML_DECL
        See Also:
        Constant Field Values
      • DEFAULT_OUTPUT_CDATA_AS_TEXT

        static final boolean DEFAULT_OUTPUT_CDATA_AS_TEXT
        See Also:
        Constant Field Values
      • DEFAULT_COPY_DEFAULT_ATTRS

        static final boolean DEFAULT_COPY_DEFAULT_ATTRS
        See Also:
        Constant Field Values
      • DEFAULT_ADD_SPACE_AFTER_EMPTY_ELEM

        static final boolean DEFAULT_ADD_SPACE_AFTER_EMPTY_ELEM
        09-Aug-2007, TSa: Space has always been added after empty element (before closing "/>"), but now it is configurable. 31-Dec-2009, TSa: Intention was to leave it enabled for backwards compatibility: but due to a bug this was NOT the case... ugh.
        See Also:
        Constant Field Values
      • DEFAULT_VALIDATE_STRUCTURE

        static final boolean DEFAULT_VALIDATE_STRUCTURE
        See Also:
        Constant Field Values
      • DEFAULT_VALIDATE_CONTENT

        static final boolean DEFAULT_VALIDATE_CONTENT
        See Also:
        Constant Field Values
      • DEFAULT_FIX_CONTENT

        static final boolean DEFAULT_FIX_CONTENT
        As per [WSTX-120], default was changed to false, from true (default prior to wstx 4.0)
        See Also:
        Constant Field Values
      • DEFAULT_FLAGS_J2ME

        static final int DEFAULT_FLAGS_J2ME
        Default config flags are converted from individual settings, to conform to Stax 1.0 specifications.
        See Also:
        Constant Field Values
      • DEFAULT_FLAGS_FULL

        static final int DEFAULT_FLAGS_FULL
        For now, full instances start with same settings as J2ME subset
        See Also:
        Constant Field Values
      • sProperties

        static final java.util.HashMap<java.lang.String,​java.lang.Integer> sProperties
        Map to use for converting from String property ids to ints described above; useful to allow use of switch later on.
      • mIsJ2MESubset

        final boolean mIsJ2MESubset
      • mConfigFlags

        protected int mConfigFlags
      • mSpecialProperties

        java.lang.Object[] mSpecialProperties
      • SP_IX_TEXT_ESCAPER_FACTORY

        private static final int SP_IX_TEXT_ESCAPER_FACTORY
        See Also:
        Constant Field Values
      • SP_IX_ATTR_VALUE_ESCAPER_FACTORY

        private static final int SP_IX_ATTR_VALUE_ESCAPER_FACTORY
        See Also:
        Constant Field Values
      • SP_IX_PROBLEM_REPORTER

        private static final int SP_IX_PROBLEM_REPORTER
        See Also:
        Constant Field Values
      • SP_IX_INVALID_CHAR_HANDLER

        private static final int SP_IX_INVALID_CHAR_HANDLER
        See Also:
        Constant Field Values
      • SP_IX_EMPTY_ELEMENT_HANDLER

        private static final int SP_IX_EMPTY_ELEMENT_HANDLER
        See Also:
        Constant Field Values
      • mRecyclerRef

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

        BufferRecycler mCurrRecycler
        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 exists, it will created first time a buffer is returned.
    • Constructor Detail

      • WriterConfig

        private WriterConfig​(WriterConfig base,
                             boolean j2meSubset,
                             int flags,
                             java.lang.Object[] specProps)
    • Method Detail

      • createJ2MEDefaults

        public static WriterConfig createJ2MEDefaults()
      • createFullDefaults

        public static WriterConfig createFullDefaults()
      • findPropertyId

        protected int findPropertyId​(java.lang.String propName)
        Specified by:
        findPropertyId in class CommonConfig
        Returns:
        Internal enumerated int matching the String name of the property, if one found: -1 to indicate no match was found.
      • setProperty

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

        public int getConfigFlags()
      • automaticNamespacesEnabled

        public boolean automaticNamespacesEnabled()
      • automaticEmptyElementsEnabled

        public boolean automaticEmptyElementsEnabled()
      • willAutoCloseOutput

        public boolean willAutoCloseOutput()
      • willSupportNamespaces

        public boolean willSupportNamespaces()
      • willUseDoubleQuotesInXmlDecl

        public boolean willUseDoubleQuotesInXmlDecl()
        Since:
        4.2.2
      • willOutputCDataAsText

        public boolean willOutputCDataAsText()
      • willCopyDefaultAttrs

        public boolean willCopyDefaultAttrs()
      • willEscapeCr

        public boolean willEscapeCr()
      • willAddSpaceAfterEmptyElem

        public boolean willAddSpaceAfterEmptyElem()
      • automaticEndElementsEnabled

        public boolean automaticEndElementsEnabled()
      • willValidateStructure

        public boolean willValidateStructure()
      • willValidateContent

        public boolean willValidateContent()
      • willValidateAttributes

        public boolean willValidateAttributes()
      • willValidateNames

        public boolean willValidateNames()
      • willFixContent

        public boolean willFixContent()
      • getAutomaticNsPrefix

        public java.lang.String getAutomaticNsPrefix()
        Returns:
        Prefix to use as the base for automatically generated namespace prefixes ("namespace prefix prefix", so to speak). Defaults to "wstxns".
      • getTextEscaperFactory

        public org.codehaus.stax2.io.EscapingWriterFactory getTextEscaperFactory()
      • getAttrValueEscaperFactory

        public org.codehaus.stax2.io.EscapingWriterFactory getAttrValueEscaperFactory()
      • getProblemReporter

        public javax.xml.stream.XMLReporter getProblemReporter()
      • enableAutomaticNamespaces

        public void enableAutomaticNamespaces​(boolean state)
      • enableAutomaticEmptyElements

        public void enableAutomaticEmptyElements​(boolean state)
      • doAutoCloseOutput

        public void doAutoCloseOutput​(boolean state)
      • doSupportNamespaces

        public void doSupportNamespaces​(boolean state)
      • doUseDoubleQuotesInXmlDecl

        public void doUseDoubleQuotesInXmlDecl​(boolean state)
        Since:
        4.2.2
      • doOutputCDataAsText

        public void doOutputCDataAsText​(boolean state)
      • doCopyDefaultAttrs

        public void doCopyDefaultAttrs​(boolean state)
      • doEscapeCr

        public void doEscapeCr​(boolean state)
      • doAddSpaceAfterEmptyElem

        public void doAddSpaceAfterEmptyElem​(boolean state)
      • enableAutomaticEndElements

        public void enableAutomaticEndElements​(boolean state)
      • doValidateStructure

        public void doValidateStructure​(boolean state)
      • doValidateContent

        public void doValidateContent​(boolean state)
      • doValidateAttributes

        public void doValidateAttributes​(boolean state)
      • doValidateNames

        public void doValidateNames​(boolean state)
      • doFixContent

        public void doFixContent​(boolean state)
      • setAutomaticNsPrefix

        public void setAutomaticNsPrefix​(java.lang.String prefix)
        Parameters:
        prefix - Prefix to use as the base for automatically generated namespace prefixes ("namespace prefix prefix", so to speak).
      • setTextEscaperFactory

        public void setTextEscaperFactory​(org.codehaus.stax2.io.EscapingWriterFactory f)
      • setAttrValueEscaperFactory

        public void setAttrValueEscaperFactory​(org.codehaus.stax2.io.EscapingWriterFactory f)
      • setProblemReporter

        public void setProblemReporter​(javax.xml.stream.XMLReporter rep)
      • configureForXmlConformance

        public void configureForXmlConformance()
        For Woodstox, this profile enables all basic well-formedness checks, including checking for name validity.
      • configureForRobustness

        public void configureForRobustness()
        For Woodstox, this profile enables all basic well-formedness checks, including checking for name validity, and also enables all matching "fix-me" properties (currently only content-fixing property exists).
      • configureForSpeed

        public void configureForSpeed()
        For Woodstox, setting this profile disables most checks for validity; specifically anything that can have measurable performance impact.
      • allocMediumCBuffer

        public char[] allocMediumCBuffer​(int minSize)
        Method called to allocate intermediate recyclable copy buffers
      • 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)
      • setConfigFlag

        private void setConfigFlag​(int flag,
                                   boolean state)
      • hasConfigFlag

        private final boolean hasConfigFlag​(int flag)
      • getSpecialProperty

        private final java.lang.Object getSpecialProperty​(int ix)
      • setSpecialProperty

        private final void setSpecialProperty​(int ix,
                                              java.lang.Object value)