Class BaseStreamWriter

  • All Implemented Interfaces:
    OutputConfigFlags, XMLStreamConstants, XMLStreamWriter, org.codehaus.stax2.typed.TypedXMLStreamWriter, org.codehaus.stax2.validation.Validatable, org.codehaus.stax2.validation.ValidationContext, org.codehaus.stax2.XMLStreamWriter2
    Direct Known Subclasses:
    TypedStreamWriter

    public abstract class BaseStreamWriter
    extends org.codehaus.stax2.ri.Stax2WriterImpl
    implements org.codehaus.stax2.validation.ValidationContext, OutputConfigFlags
    Base class for XMLStreamWriter implementations Woodstox has. Contains partial stream writer implementation, plus utility methods shared by concrete implementation classes. Main reason for such abstract base class is to allow other parts of Woodstox core to refer to any of stream writer implementations in general way.
    • Field Detail

      • MIN_ARRAYCOPY

        protected static final int MIN_ARRAYCOPY
        This constant defines minimum length of a String, for which it is beneficial to do an intermediate copy (using String.getChars()), and iterate over intermediate array, instead of iterating using String.charAt(). Former is generally faster for longer Strings, but has some overhead for shorter Strings. Tests indicate that the threshold is somewhere between 8 and 16 characters, at least on x86 platform.
        See Also:
        Constant Field Values
      • DEFAULT_COPYBUFFER_LEN

        protected static final int DEFAULT_COPYBUFFER_LEN
        See Also:
        Constant Field Values
      • mWriter

        protected final XmlWriter mWriter
        Actual physical writer to output serialized XML content to
      • mCopyBuffer

        protected char[] mCopyBuffer
        Intermediate buffer into which characters of a String can be copied, in cases where such a copy followed by array access is faster than calling String.charAt() (which perhaps surprisingly is often case, and especially significant for longer buffers).
      • mCfgCDataAsText

        protected final boolean mCfgCDataAsText
      • mCfgCopyDefaultAttrs

        protected final boolean mCfgCopyDefaultAttrs
      • mCfgAutomaticEmptyElems

        protected final boolean mCfgAutomaticEmptyElems
      • mCheckStructure

        protected boolean mCheckStructure
      • mCheckAttrs

        protected boolean mCheckAttrs
      • mEncoding

        protected String mEncoding
        Encoding to use; may be passed from the factory (when a method that defines encoding is used), updated by a call to writeStartDocument(), or null if neither. Is passed to the escaping writer factory to allow escaping writers to do additional escaping if necessary (like encapsulating non-ascii chars in a doc encoded usig ascii).
      • mValidator

        protected org.codehaus.stax2.validation.XMLValidator mValidator
        Optional validator to use for validating output against one or more schemas, and/or for safe pretty-printing (indentation).
      • mXml11

        protected boolean mXml11
        Since XML 1.1 has some differences to 1.0, we need to keep a flag to indicate if we were to output XML 1.1 document.
      • mVldProbHandler

        protected org.codehaus.stax2.validation.ValidationProblemHandler mVldProbHandler
        Custom validation problem handler, if any.
      • mState

        protected int mState
      • mAnyOutput

        protected boolean mAnyOutput
        Flag that is set to true first time something has been output. Generally needed to keep track of whether XML declaration (START_DOCUMENT) can be output or not.
      • mStartElementOpen

        protected boolean mStartElementOpen
        Flag that is set during time that a start element is "open", ie. START_ELEMENT has been output (and possibly zero or more name space declarations and attributes), before other main-level constructs have been output.
      • mEmptyElement

        protected boolean mEmptyElement
        Flag that indicates that current element is an empty element (one that is explicitly defined as one, by calling a method -- NOT one that just happens to be empty). This is needed to know what to do when next non-ns/attr node is output; normally a new context is opened, but for empty elements not.
      • mVldContent

        protected int mVldContent
        State value used with validation, to track types of content that is allowed at this point in output stream. Only used if validation is enabled: if so, value is determined via validation callbacks.
      • mDtdRootElem

        protected String mDtdRootElem
        Value passed as the expected root element, when using the multiple argument writeDTD(java.lang.String) method. Will be used in structurally validating mode (and in dtd-validating mode, since that automatically enables structural validation as well, to pre-filter well-formedness errors that validators might have trouble dealing with).
      • mReturnNullForDefaultNamespace

        protected boolean mReturnNullForDefaultNamespace