Class BaseStreamWriter

  • All Implemented Interfaces:
    OutputConfigFlags, javax.xml.stream.XMLStreamConstants, javax.xml.stream.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.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      private void _finishDocument​(boolean forceRealClose)  
      int addDefaultAttribute​(java.lang.String localName, java.lang.String uri, java.lang.String prefix, java.lang.String value)
      Adding default attribute values does not usually make sense on output side, so the implementation is a NOP for now.
      void close()  
      void closeCompletely()  
      protected abstract void closeStartElement​(boolean emptyElem)
      Method called to close an open start element, when another main-level element (not namespace declaration or attribute) is being output; except for end element which is handled differently.
      void copyEventFromReader​(org.codehaus.stax2.XMLStreamReader2 sr, boolean preserveEventData)
      Method that essentially copies event that the specified reader has just read.
      abstract void copyStartElement​(InputElementStack elemStack, AttributeCollector attrCollector)
      Implementation-dependant method called to fully copy START_ELEMENT event that the passed-in stream reader points to
      protected void doReportProblem​(javax.xml.stream.XMLReporter rep, java.lang.String probType, java.lang.String msg, javax.xml.stream.Location loc)  
      protected void doReportProblem​(javax.xml.stream.XMLReporter rep, org.codehaus.stax2.validation.XMLValidationProblem prob)  
      protected void doWriteStartDocument​(java.lang.String version, java.lang.String encoding, java.lang.String standAlone)  
      int findAttributeIndex​(java.lang.String nsURI, java.lang.String localName)  
      void flush()  
      int getAttributeCount()  
      java.lang.String getAttributeLocalName​(int index)  
      java.lang.String getAttributeNamespace​(int index)  
      java.lang.String getAttributePrefix​(int index)  
      java.lang.String getAttributeType​(int index)  
      java.lang.String getAttributeValue​(int index)  
      java.lang.String getAttributeValue​(java.lang.String nsURI, java.lang.String localName)  
      java.lang.String getBaseUri()
      As of now, there is no way to specify the base URI.
      protected char[] getCopyBuffer()  
      protected char[] getCopyBuffer​(int minLen)  
      abstract javax.xml.namespace.QName getCurrentElementName()  
      java.lang.String getEncoding()  
      org.codehaus.stax2.XMLStreamLocation2 getLocation()  
      abstract javax.xml.namespace.NamespaceContext getNamespaceContext()  
      abstract java.lang.String getNamespaceURI​(java.lang.String prefix)  
      abstract java.lang.String getPrefix​(java.lang.String uri)  
      java.lang.Object getProperty​(java.lang.String name)  
      protected abstract java.lang.String getTopElementDesc()
      Method needed for error message generation
      javax.xml.stream.Location getValidationLocation()  
      java.lang.String getXmlVersion()  
      protected boolean inPrologOrEpilog()  
      boolean isNotationDeclared​(java.lang.String name)  
      boolean isPropertySupported​(java.lang.String name)  
      boolean isUnparsedEntityDeclared​(java.lang.String name)  
      protected boolean isValidating()
      Method that is used by output classes to determine whether we are in validating mode.
      protected static void reportIllegalArg​(java.lang.String msg)  
      protected static void reportIllegalMethod​(java.lang.String msg)
      Method called when an illegal method (namespace-specific method on non-ns writer) is called by the application.
      protected void reportInvalidContent​(int evtType)  
      protected static void reportNwfAttr​(java.lang.String msg)
      This is the method called when an output method call violates attribute well-formedness checks (trying to output dup attrs) and WstxOutputProperties.P_OUTPUT_VALIDATE_NAMES is is enabled.
      protected static void reportNwfAttr​(java.lang.String msg, java.lang.Object arg)  
      protected static void reportNwfContent​(java.lang.String msg)
      This is the method called when an output method call violates content well-formedness checks and WstxOutputProperties.P_OUTPUT_VALIDATE_CONTENT is is enabled.
      protected static void reportNwfContent​(java.lang.String msg, java.lang.Object arg)  
      protected static void reportNwfStructure​(java.lang.String msg)
      This is the method called when an output method call violates structural well-formedness checks and WstxOutputProperties.P_OUTPUT_VALIDATE_STRUCTURE is is enabled.
      protected static void reportNwfStructure​(java.lang.String msg, java.lang.Object arg)  
      void reportProblem​(org.codehaus.stax2.validation.XMLValidationProblem prob)  
      void reportValidationProblem​(java.lang.String msg)  
      void reportValidationProblem​(java.lang.String msg, int severity)  
      void reportValidationProblem​(java.lang.String format, java.lang.Object arg)  
      void reportValidationProblem​(java.lang.String format, java.lang.Object arg, java.lang.Object arg2)  
      void reportValidationProblem​(java.lang.String msg, javax.xml.stream.Location loc, int severity)  
      void reportValidationProblem​(javax.xml.stream.Location loc, java.lang.String msg)  
      private void resetValidationFlags()  
      abstract void setDefaultNamespace​(java.lang.String uri)  
      abstract void setNamespaceContext​(javax.xml.namespace.NamespaceContext context)  
      abstract void setPrefix​(java.lang.String prefix, java.lang.String uri)  
      boolean setProperty​(java.lang.String name, java.lang.Object value)  
      org.codehaus.stax2.validation.ValidationProblemHandler setValidationProblemHandler​(org.codehaus.stax2.validation.ValidationProblemHandler h)  
      org.codehaus.stax2.validation.XMLValidator stopValidatingAgainst​(org.codehaus.stax2.validation.XMLValidationSchema schema)  
      org.codehaus.stax2.validation.XMLValidator stopValidatingAgainst​(org.codehaus.stax2.validation.XMLValidator validator)  
      protected static void throwFromIOE​(java.io.IOException ioe)  
      protected static void throwOutputError​(java.lang.String msg)  
      protected static void throwOutputError​(java.lang.String format, java.lang.Object arg)  
      java.lang.String toString()  
      org.codehaus.stax2.validation.XMLValidator validateAgainst​(org.codehaus.stax2.validation.XMLValidationSchema schema)  
      abstract java.lang.String validateQNamePrefix​(javax.xml.namespace.QName name)
      Method called before writing a QName via Typed Access API.
      protected void verifyRootElement​(java.lang.String localName, java.lang.String prefix)  
      protected void verifyWriteCData()  
      protected void verifyWriteDTD()  
      java.io.Writer wrapAsRawWriter()
      Method that can be called to get a wrapper instance that can be used to essentially call the writeRaw method via regular Writer interface.
      java.io.Writer wrapAsTextWriter()
      Method that can be called to get a wrapper instance that can be used to essentially call the writeCharacters method via regular Writer interface.
      abstract void writeAttribute​(java.lang.String localName, java.lang.String value)  
      abstract void writeAttribute​(java.lang.String nsURI, java.lang.String localName, java.lang.String value)  
      abstract void writeAttribute​(java.lang.String prefix, java.lang.String nsURI, java.lang.String localName, java.lang.String value)  
      void writeCData​(char[] cbuf, int start, int len)  
      void writeCData​(java.lang.String data)  
      void writeCharacters​(char[] text, int start, int len)  
      void writeCharacters​(java.lang.String text)  
      void writeCharacters​(javax.xml.stream.events.Characters ch)
      Method called by XMLEventWriter (instead of more generic text output methods), so that we can verify (if necessary) that this character output type is legal in this context.
      void writeComment​(java.lang.String data)  
      abstract void writeDefaultNamespace​(java.lang.String nsURI)  
      void writeDTD​(java.lang.String dtd)  
      void writeDTD​(java.lang.String rootName, java.lang.String systemId, java.lang.String publicId, java.lang.String internalSubset)  
      void writeDTD​(org.codehaus.stax2.DTDInfo info)  
      abstract void writeEmptyElement​(java.lang.String localName)  
      abstract void writeEmptyElement​(java.lang.String nsURI, java.lang.String localName)  
      abstract void writeEmptyElement​(java.lang.String prefix, java.lang.String localName, java.lang.String nsURI)  
      void writeEndDocument()  
      abstract void writeEndElement()  
      abstract void writeEndElement​(javax.xml.namespace.QName name)
      Method called by XMLEventWriter (instead of the version that takes no argument), so that we can verify it does match the start element if necessary.
      void writeEntityRef​(java.lang.String name)  
      abstract void writeFullEndElement()  
      abstract void writeNamespace​(java.lang.String prefix, java.lang.String nsURI)  
      void writeProcessingInstruction​(java.lang.String target)  
      void writeProcessingInstruction​(java.lang.String target, java.lang.String data)  
      void writeRaw​(char[] text, int start, int offset)  
      void writeRaw​(java.lang.String text)  
      void writeRaw​(java.lang.String text, int start, int offset)  
      void writeSpace​(char[] text, int offset, int length)  
      void writeSpace​(java.lang.String text)  
      void writeStartDocument()  
      void writeStartDocument​(java.lang.String version)  
      void writeStartDocument​(java.lang.String encoding, java.lang.String version)  
      void writeStartDocument​(java.lang.String version, java.lang.String encoding, boolean standAlone)  
      abstract void writeStartElement​(java.lang.String localName)  
      abstract void writeStartElement​(java.lang.String nsURI, java.lang.String localName)  
      abstract void writeStartElement​(java.lang.String prefix, java.lang.String localName, java.lang.String nsURI)  
      abstract void writeStartElement​(javax.xml.stream.events.StartElement elem)
      Convenience method needed by XMLEventWriter implementation, to use when writing a start element, and possibly its attributes and namespace declarations.
      • Methods inherited from class org.codehaus.stax2.ri.Stax2WriterImpl

        copyStartElement
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.codehaus.stax2.typed.TypedXMLStreamWriter

        writeBinary, writeBinary, writeBinaryAttribute, writeBinaryAttribute, writeBoolean, writeBooleanAttribute, writeDecimal, writeDecimalAttribute, writeDouble, writeDoubleArray, writeDoubleArrayAttribute, writeDoubleAttribute, writeFloat, writeFloatArray, writeFloatArrayAttribute, writeFloatAttribute, writeInt, writeIntArray, writeIntArrayAttribute, writeIntAttribute, writeInteger, writeIntegerAttribute, writeLong, writeLongArray, writeLongArrayAttribute, writeLongAttribute, writeQName, writeQNameAttribute
    • 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 java.lang.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 java.lang.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
    • Constructor Detail

      • BaseStreamWriter

        protected BaseStreamWriter​(XmlWriter xw,
                                   java.lang.String enc,
                                   WriterConfig cfg)
    • Method Detail

      • close

        public void close()
                   throws javax.xml.stream.XMLStreamException
        Specified by:
        close in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • flush

        public void flush()
                   throws javax.xml.stream.XMLStreamException
        Specified by:
        flush in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • getNamespaceContext

        public abstract javax.xml.namespace.NamespaceContext getNamespaceContext()
        Specified by:
        getNamespaceContext in interface javax.xml.stream.XMLStreamWriter
      • getPrefix

        public abstract java.lang.String getPrefix​(java.lang.String uri)
        Specified by:
        getPrefix in interface javax.xml.stream.XMLStreamWriter
      • getProperty

        public java.lang.Object getProperty​(java.lang.String name)
        Specified by:
        getProperty in interface javax.xml.stream.XMLStreamWriter
      • setDefaultNamespace

        public abstract void setDefaultNamespace​(java.lang.String uri)
                                          throws javax.xml.stream.XMLStreamException
        Specified by:
        setDefaultNamespace in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • setNamespaceContext

        public abstract void setNamespaceContext​(javax.xml.namespace.NamespaceContext context)
                                          throws javax.xml.stream.XMLStreamException
        Specified by:
        setNamespaceContext in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • setPrefix

        public abstract void setPrefix​(java.lang.String prefix,
                                       java.lang.String uri)
                                throws javax.xml.stream.XMLStreamException
        Specified by:
        setPrefix in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeAttribute

        public abstract void writeAttribute​(java.lang.String localName,
                                            java.lang.String value)
                                     throws javax.xml.stream.XMLStreamException
        Specified by:
        writeAttribute in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeAttribute

        public abstract void writeAttribute​(java.lang.String nsURI,
                                            java.lang.String localName,
                                            java.lang.String value)
                                     throws javax.xml.stream.XMLStreamException
        Specified by:
        writeAttribute in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeAttribute

        public abstract void writeAttribute​(java.lang.String prefix,
                                            java.lang.String nsURI,
                                            java.lang.String localName,
                                            java.lang.String value)
                                     throws javax.xml.stream.XMLStreamException
        Specified by:
        writeAttribute in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeCData

        public void writeCData​(java.lang.String data)
                        throws javax.xml.stream.XMLStreamException
        Specified by:
        writeCData in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeCharacters

        public void writeCharacters​(char[] text,
                                    int start,
                                    int len)
                             throws javax.xml.stream.XMLStreamException
        Specified by:
        writeCharacters in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeCharacters

        public void writeCharacters​(java.lang.String text)
                             throws javax.xml.stream.XMLStreamException
        Specified by:
        writeCharacters in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeComment

        public void writeComment​(java.lang.String data)
                          throws javax.xml.stream.XMLStreamException
        Specified by:
        writeComment in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeDefaultNamespace

        public abstract void writeDefaultNamespace​(java.lang.String nsURI)
                                            throws javax.xml.stream.XMLStreamException
        Specified by:
        writeDefaultNamespace in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeDTD

        public void writeDTD​(java.lang.String dtd)
                      throws javax.xml.stream.XMLStreamException
        Specified by:
        writeDTD in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeEmptyElement

        public abstract void writeEmptyElement​(java.lang.String localName)
                                        throws javax.xml.stream.XMLStreamException
        Specified by:
        writeEmptyElement in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeEmptyElement

        public abstract void writeEmptyElement​(java.lang.String nsURI,
                                               java.lang.String localName)
                                        throws javax.xml.stream.XMLStreamException
        Specified by:
        writeEmptyElement in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeEmptyElement

        public abstract void writeEmptyElement​(java.lang.String prefix,
                                               java.lang.String localName,
                                               java.lang.String nsURI)
                                        throws javax.xml.stream.XMLStreamException
        Specified by:
        writeEmptyElement in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeEndDocument

        public void writeEndDocument()
                              throws javax.xml.stream.XMLStreamException
        Specified by:
        writeEndDocument in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeEndElement

        public abstract void writeEndElement()
                                      throws javax.xml.stream.XMLStreamException
        Specified by:
        writeEndElement in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeEntityRef

        public void writeEntityRef​(java.lang.String name)
                            throws javax.xml.stream.XMLStreamException
        Specified by:
        writeEntityRef in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeNamespace

        public abstract void writeNamespace​(java.lang.String prefix,
                                            java.lang.String nsURI)
                                     throws javax.xml.stream.XMLStreamException
        Specified by:
        writeNamespace in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeProcessingInstruction

        public void writeProcessingInstruction​(java.lang.String target)
                                        throws javax.xml.stream.XMLStreamException
        Specified by:
        writeProcessingInstruction in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeProcessingInstruction

        public void writeProcessingInstruction​(java.lang.String target,
                                               java.lang.String data)
                                        throws javax.xml.stream.XMLStreamException
        Specified by:
        writeProcessingInstruction in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeStartDocument

        public void writeStartDocument()
                                throws javax.xml.stream.XMLStreamException
        Specified by:
        writeStartDocument in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeStartDocument

        public void writeStartDocument​(java.lang.String version)
                                throws javax.xml.stream.XMLStreamException
        Specified by:
        writeStartDocument in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeStartDocument

        public void writeStartDocument​(java.lang.String encoding,
                                       java.lang.String version)
                                throws javax.xml.stream.XMLStreamException
        Specified by:
        writeStartDocument in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • doWriteStartDocument

        protected void doWriteStartDocument​(java.lang.String version,
                                            java.lang.String encoding,
                                            java.lang.String standAlone)
                                     throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • writeStartElement

        public abstract void writeStartElement​(java.lang.String localName)
                                        throws javax.xml.stream.XMLStreamException
        Specified by:
        writeStartElement in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeStartElement

        public abstract void writeStartElement​(java.lang.String nsURI,
                                               java.lang.String localName)
                                        throws javax.xml.stream.XMLStreamException
        Specified by:
        writeStartElement in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • writeStartElement

        public abstract void writeStartElement​(java.lang.String prefix,
                                               java.lang.String localName,
                                               java.lang.String nsURI)
                                        throws javax.xml.stream.XMLStreamException
        Specified by:
        writeStartElement in interface javax.xml.stream.XMLStreamWriter
        Throws:
        javax.xml.stream.XMLStreamException
      • copyEventFromReader

        public void copyEventFromReader​(org.codehaus.stax2.XMLStreamReader2 sr,
                                        boolean preserveEventData)
                                 throws javax.xml.stream.XMLStreamException
        Method that essentially copies event that the specified reader has just read.
        Specified by:
        copyEventFromReader in interface org.codehaus.stax2.XMLStreamWriter2
        Overrides:
        copyEventFromReader in class org.codehaus.stax2.ri.Stax2WriterImpl
        Parameters:
        sr - Stream reader to use for accessing event to copy
        preserveEventData - If true, writer is not allowed to change the state of the reader (so that all the data associated with the current event has to be preserved); if false, writer is allowed to use methods that may cause some data to be discarded. Setting this to false may improve the performance, since it may allow full no-copy streaming of data, especially textual contents.
        Throws:
        javax.xml.stream.XMLStreamException
      • closeCompletely

        public void closeCompletely()
                             throws javax.xml.stream.XMLStreamException
        Specified by:
        closeCompletely in interface org.codehaus.stax2.XMLStreamWriter2
        Throws:
        javax.xml.stream.XMLStreamException
      • isPropertySupported

        public boolean isPropertySupported​(java.lang.String name)
        Specified by:
        isPropertySupported in interface org.codehaus.stax2.XMLStreamWriter2
        Overrides:
        isPropertySupported in class org.codehaus.stax2.ri.Stax2WriterImpl
      • setProperty

        public boolean setProperty​(java.lang.String name,
                                   java.lang.Object value)
        Specified by:
        setProperty in interface org.codehaus.stax2.XMLStreamWriter2
        Overrides:
        setProperty in class org.codehaus.stax2.ri.Stax2WriterImpl
        Parameters:
        name - Name of the property to set
        value - Value to set property to.
        Returns:
        True, if the specified property was succesfully set to specified value; false if its value was not changed
      • validateAgainst

        public org.codehaus.stax2.validation.XMLValidator validateAgainst​(org.codehaus.stax2.validation.XMLValidationSchema schema)
                                                                   throws javax.xml.stream.XMLStreamException
        Specified by:
        validateAgainst in interface org.codehaus.stax2.validation.Validatable
        Overrides:
        validateAgainst in class org.codehaus.stax2.ri.Stax2WriterImpl
        Throws:
        javax.xml.stream.XMLStreamException
      • stopValidatingAgainst

        public org.codehaus.stax2.validation.XMLValidator stopValidatingAgainst​(org.codehaus.stax2.validation.XMLValidationSchema schema)
                                                                         throws javax.xml.stream.XMLStreamException
        Specified by:
        stopValidatingAgainst in interface org.codehaus.stax2.validation.Validatable
        Overrides:
        stopValidatingAgainst in class org.codehaus.stax2.ri.Stax2WriterImpl
        Throws:
        javax.xml.stream.XMLStreamException
      • stopValidatingAgainst

        public org.codehaus.stax2.validation.XMLValidator stopValidatingAgainst​(org.codehaus.stax2.validation.XMLValidator validator)
                                                                         throws javax.xml.stream.XMLStreamException
        Specified by:
        stopValidatingAgainst in interface org.codehaus.stax2.validation.Validatable
        Overrides:
        stopValidatingAgainst in class org.codehaus.stax2.ri.Stax2WriterImpl
        Throws:
        javax.xml.stream.XMLStreamException
      • setValidationProblemHandler

        public org.codehaus.stax2.validation.ValidationProblemHandler setValidationProblemHandler​(org.codehaus.stax2.validation.ValidationProblemHandler h)
        Specified by:
        setValidationProblemHandler in interface org.codehaus.stax2.validation.Validatable
        Overrides:
        setValidationProblemHandler in class org.codehaus.stax2.ri.Stax2WriterImpl
      • resetValidationFlags

        private void resetValidationFlags()
      • getLocation

        public org.codehaus.stax2.XMLStreamLocation2 getLocation()
        Specified by:
        getLocation in interface org.codehaus.stax2.XMLStreamWriter2
        Specified by:
        getLocation in class org.codehaus.stax2.ri.Stax2WriterImpl
      • getEncoding

        public java.lang.String getEncoding()
        Specified by:
        getEncoding in interface org.codehaus.stax2.XMLStreamWriter2
        Specified by:
        getEncoding in class org.codehaus.stax2.ri.Stax2WriterImpl
      • writeCData

        public void writeCData​(char[] cbuf,
                               int start,
                               int len)
                        throws javax.xml.stream.XMLStreamException
        Specified by:
        writeCData in interface org.codehaus.stax2.XMLStreamWriter2
        Overrides:
        writeCData in class org.codehaus.stax2.ri.Stax2WriterImpl
        Throws:
        javax.xml.stream.XMLStreamException
      • writeDTD

        public void writeDTD​(org.codehaus.stax2.DTDInfo info)
                      throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • writeDTD

        public void writeDTD​(java.lang.String rootName,
                             java.lang.String systemId,
                             java.lang.String publicId,
                             java.lang.String internalSubset)
                      throws javax.xml.stream.XMLStreamException
        Specified by:
        writeDTD in interface org.codehaus.stax2.XMLStreamWriter2
        Overrides:
        writeDTD in class org.codehaus.stax2.ri.Stax2WriterImpl
        Throws:
        javax.xml.stream.XMLStreamException
      • writeFullEndElement

        public abstract void writeFullEndElement()
                                          throws javax.xml.stream.XMLStreamException
        Specified by:
        writeFullEndElement in interface org.codehaus.stax2.XMLStreamWriter2
        Overrides:
        writeFullEndElement in class org.codehaus.stax2.ri.Stax2WriterImpl
        Throws:
        javax.xml.stream.XMLStreamException
      • writeStartDocument

        public void writeStartDocument​(java.lang.String version,
                                       java.lang.String encoding,
                                       boolean standAlone)
                                throws javax.xml.stream.XMLStreamException
        Specified by:
        writeStartDocument in interface org.codehaus.stax2.XMLStreamWriter2
        Specified by:
        writeStartDocument in class org.codehaus.stax2.ri.Stax2WriterImpl
        Throws:
        javax.xml.stream.XMLStreamException
      • writeRaw

        public void writeRaw​(java.lang.String text)
                      throws javax.xml.stream.XMLStreamException
        Specified by:
        writeRaw in interface org.codehaus.stax2.XMLStreamWriter2
        Overrides:
        writeRaw in class org.codehaus.stax2.ri.Stax2WriterImpl
        Throws:
        javax.xml.stream.XMLStreamException
      • writeRaw

        public void writeRaw​(java.lang.String text,
                             int start,
                             int offset)
                      throws javax.xml.stream.XMLStreamException
        Specified by:
        writeRaw in interface org.codehaus.stax2.XMLStreamWriter2
        Specified by:
        writeRaw in class org.codehaus.stax2.ri.Stax2WriterImpl
        Throws:
        javax.xml.stream.XMLStreamException
      • writeRaw

        public void writeRaw​(char[] text,
                             int start,
                             int offset)
                      throws javax.xml.stream.XMLStreamException
        Specified by:
        writeRaw in interface org.codehaus.stax2.XMLStreamWriter2
        Specified by:
        writeRaw in class org.codehaus.stax2.ri.Stax2WriterImpl
        Throws:
        javax.xml.stream.XMLStreamException
      • writeSpace

        public void writeSpace​(java.lang.String text)
                        throws javax.xml.stream.XMLStreamException
        Specified by:
        writeSpace in interface org.codehaus.stax2.XMLStreamWriter2
        Overrides:
        writeSpace in class org.codehaus.stax2.ri.Stax2WriterImpl
        Throws:
        javax.xml.stream.XMLStreamException
      • writeSpace

        public void writeSpace​(char[] text,
                               int offset,
                               int length)
                        throws javax.xml.stream.XMLStreamException
        Specified by:
        writeSpace in interface org.codehaus.stax2.XMLStreamWriter2
        Overrides:
        writeSpace in class org.codehaus.stax2.ri.Stax2WriterImpl
        Throws:
        javax.xml.stream.XMLStreamException
      • getXmlVersion

        public java.lang.String getXmlVersion()
        Specified by:
        getXmlVersion in interface org.codehaus.stax2.validation.ValidationContext
      • getCurrentElementName

        public abstract javax.xml.namespace.QName getCurrentElementName()
        Specified by:
        getCurrentElementName in interface org.codehaus.stax2.validation.ValidationContext
      • getNamespaceURI

        public abstract java.lang.String getNamespaceURI​(java.lang.String prefix)
        Specified by:
        getNamespaceURI in interface org.codehaus.stax2.validation.ValidationContext
      • getBaseUri

        public java.lang.String getBaseUri()
        As of now, there is no way to specify the base URI. Could be improved in future, if xml:base is supported.
        Specified by:
        getBaseUri in interface org.codehaus.stax2.validation.ValidationContext
      • getValidationLocation

        public javax.xml.stream.Location getValidationLocation()
        Specified by:
        getValidationLocation in interface org.codehaus.stax2.validation.ValidationContext
      • reportProblem

        public void reportProblem​(org.codehaus.stax2.validation.XMLValidationProblem prob)
                           throws javax.xml.stream.XMLStreamException
        Specified by:
        reportProblem in interface org.codehaus.stax2.validation.ValidationContext
        Throws:
        javax.xml.stream.XMLStreamException
      • addDefaultAttribute

        public int addDefaultAttribute​(java.lang.String localName,
                                       java.lang.String uri,
                                       java.lang.String prefix,
                                       java.lang.String value)
        Adding default attribute values does not usually make sense on output side, so the implementation is a NOP for now.
        Specified by:
        addDefaultAttribute in interface org.codehaus.stax2.validation.ValidationContext
      • isNotationDeclared

        public boolean isNotationDeclared​(java.lang.String name)
        Specified by:
        isNotationDeclared in interface org.codehaus.stax2.validation.ValidationContext
      • isUnparsedEntityDeclared

        public boolean isUnparsedEntityDeclared​(java.lang.String name)
        Specified by:
        isUnparsedEntityDeclared in interface org.codehaus.stax2.validation.ValidationContext
      • getAttributeCount

        public int getAttributeCount()
        Specified by:
        getAttributeCount in interface org.codehaus.stax2.validation.ValidationContext
      • getAttributeLocalName

        public java.lang.String getAttributeLocalName​(int index)
        Specified by:
        getAttributeLocalName in interface org.codehaus.stax2.validation.ValidationContext
      • getAttributeNamespace

        public java.lang.String getAttributeNamespace​(int index)
        Specified by:
        getAttributeNamespace in interface org.codehaus.stax2.validation.ValidationContext
      • getAttributePrefix

        public java.lang.String getAttributePrefix​(int index)
        Specified by:
        getAttributePrefix in interface org.codehaus.stax2.validation.ValidationContext
      • getAttributeValue

        public java.lang.String getAttributeValue​(int index)
        Specified by:
        getAttributeValue in interface org.codehaus.stax2.validation.ValidationContext
      • getAttributeValue

        public java.lang.String getAttributeValue​(java.lang.String nsURI,
                                                  java.lang.String localName)
        Specified by:
        getAttributeValue in interface org.codehaus.stax2.validation.ValidationContext
      • getAttributeType

        public java.lang.String getAttributeType​(int index)
        Specified by:
        getAttributeType in interface org.codehaus.stax2.validation.ValidationContext
      • findAttributeIndex

        public int findAttributeIndex​(java.lang.String nsURI,
                                      java.lang.String localName)
        Specified by:
        findAttributeIndex in interface org.codehaus.stax2.validation.ValidationContext
      • wrapAsRawWriter

        public final java.io.Writer wrapAsRawWriter()
        Method that can be called to get a wrapper instance that can be used to essentially call the writeRaw method via regular Writer interface.
      • wrapAsTextWriter

        public final java.io.Writer wrapAsTextWriter()
        Method that can be called to get a wrapper instance that can be used to essentially call the writeCharacters method via regular Writer interface.
      • isValidating

        protected boolean isValidating()
        Method that is used by output classes to determine whether we are in validating mode.

        Note: current implementation of this method is not perfect; it may be possible it can return true even if we are only using a DTD to get some limited info, without validating?

      • writeStartElement

        public abstract void writeStartElement​(javax.xml.stream.events.StartElement elem)
                                        throws javax.xml.stream.XMLStreamException
        Convenience method needed by XMLEventWriter implementation, to use when writing a start element, and possibly its attributes and namespace declarations.
        Throws:
        javax.xml.stream.XMLStreamException
      • writeEndElement

        public abstract void writeEndElement​(javax.xml.namespace.QName name)
                                      throws javax.xml.stream.XMLStreamException
        Method called by XMLEventWriter (instead of the version that takes no argument), so that we can verify it does match the start element if necessary.
        Throws:
        javax.xml.stream.XMLStreamException
      • writeCharacters

        public void writeCharacters​(javax.xml.stream.events.Characters ch)
                             throws javax.xml.stream.XMLStreamException
        Method called by XMLEventWriter (instead of more generic text output methods), so that we can verify (if necessary) that this character output type is legal in this context. Specifically, it's not acceptable to add non-whitespace content outside root element (in prolog/epilog).

        Note: cut'n pasted from the main writeCharacters; not good... but done to optimize white-space cases.

        Throws:
        javax.xml.stream.XMLStreamException
      • closeStartElement

        protected abstract void closeStartElement​(boolean emptyElem)
                                           throws javax.xml.stream.XMLStreamException
        Method called to close an open start element, when another main-level element (not namespace declaration or attribute) is being output; except for end element which is handled differently.
        Throws:
        javax.xml.stream.XMLStreamException
      • inPrologOrEpilog

        protected final boolean inPrologOrEpilog()
      • _finishDocument

        private final void _finishDocument​(boolean forceRealClose)
                                    throws javax.xml.stream.XMLStreamException
        Parameters:
        forceRealClose - If true, will force calling of close() on the underlying physical result (stream, writer). If false, will let XmlWriter decide whether to call close(); will be done if auto-closing enabled, but not otherwise.
        Throws:
        javax.xml.stream.XMLStreamException
      • copyStartElement

        public abstract void copyStartElement​(InputElementStack elemStack,
                                              AttributeCollector attrCollector)
                                       throws java.io.IOException,
                                              javax.xml.stream.XMLStreamException
        Implementation-dependant method called to fully copy START_ELEMENT event that the passed-in stream reader points to
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • validateQNamePrefix

        public abstract java.lang.String validateQNamePrefix​(javax.xml.namespace.QName name)
                                                      throws javax.xml.stream.XMLStreamException
        Method called before writing a QName via Typed Access API. In namespace-repairing mode it should take appropriate actions to ensure that the given namespace URI is bound to a namespace and return whatever it maps to. In non-repairing work no additional work is to be done and methods
        Returns:
        Prefix to use when writing out given QName as an element or attribute value
        Throws:
        javax.xml.stream.XMLStreamException
      • verifyWriteCData

        protected final void verifyWriteCData()
                                       throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • verifyWriteDTD

        protected final void verifyWriteDTD()
                                     throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • verifyRootElement

        protected void verifyRootElement​(java.lang.String localName,
                                         java.lang.String prefix)
                                  throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • throwOutputError

        protected static void throwOutputError​(java.lang.String msg)
                                        throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • throwOutputError

        protected static void throwOutputError​(java.lang.String format,
                                               java.lang.Object arg)
                                        throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • reportIllegalMethod

        protected static void reportIllegalMethod​(java.lang.String msg)
                                           throws javax.xml.stream.XMLStreamException
        Method called when an illegal method (namespace-specific method on non-ns writer) is called by the application.
        Throws:
        javax.xml.stream.XMLStreamException
      • reportNwfStructure

        protected static void reportNwfStructure​(java.lang.String msg)
                                          throws javax.xml.stream.XMLStreamException
        This is the method called when an output method call violates structural well-formedness checks and WstxOutputProperties.P_OUTPUT_VALIDATE_STRUCTURE is is enabled.
        Throws:
        javax.xml.stream.XMLStreamException
      • reportNwfStructure

        protected static void reportNwfStructure​(java.lang.String msg,
                                                 java.lang.Object arg)
                                          throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • reportNwfContent

        protected static void reportNwfContent​(java.lang.String msg)
                                        throws javax.xml.stream.XMLStreamException
        This is the method called when an output method call violates content well-formedness checks and WstxOutputProperties.P_OUTPUT_VALIDATE_CONTENT is is enabled.
        Throws:
        javax.xml.stream.XMLStreamException
      • reportNwfContent

        protected static void reportNwfContent​(java.lang.String msg,
                                               java.lang.Object arg)
                                        throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • reportNwfAttr

        protected static void reportNwfAttr​(java.lang.String msg)
                                     throws javax.xml.stream.XMLStreamException
        This is the method called when an output method call violates attribute well-formedness checks (trying to output dup attrs) and WstxOutputProperties.P_OUTPUT_VALIDATE_NAMES is is enabled.
        Throws:
        javax.xml.stream.XMLStreamException
      • reportNwfAttr

        protected static void reportNwfAttr​(java.lang.String msg,
                                            java.lang.Object arg)
                                     throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • throwFromIOE

        protected static void throwFromIOE​(java.io.IOException ioe)
                                    throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • reportIllegalArg

        protected static void reportIllegalArg​(java.lang.String msg)
                                        throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • reportInvalidContent

        protected void reportInvalidContent​(int evtType)
                                     throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • reportValidationProblem

        public void reportValidationProblem​(java.lang.String msg,
                                            javax.xml.stream.Location loc,
                                            int severity)
                                     throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • reportValidationProblem

        public void reportValidationProblem​(java.lang.String msg,
                                            int severity)
                                     throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • reportValidationProblem

        public void reportValidationProblem​(java.lang.String msg)
                                     throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • reportValidationProblem

        public void reportValidationProblem​(javax.xml.stream.Location loc,
                                            java.lang.String msg)
                                     throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • reportValidationProblem

        public void reportValidationProblem​(java.lang.String format,
                                            java.lang.Object arg)
                                     throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • reportValidationProblem

        public void reportValidationProblem​(java.lang.String format,
                                            java.lang.Object arg,
                                            java.lang.Object arg2)
                                     throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • doReportProblem

        protected void doReportProblem​(javax.xml.stream.XMLReporter rep,
                                       java.lang.String probType,
                                       java.lang.String msg,
                                       javax.xml.stream.Location loc)
                                throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • doReportProblem

        protected void doReportProblem​(javax.xml.stream.XMLReporter rep,
                                       org.codehaus.stax2.validation.XMLValidationProblem prob)
                                throws javax.xml.stream.XMLStreamException
        Throws:
        javax.xml.stream.XMLStreamException
      • getTopElementDesc

        protected abstract java.lang.String getTopElementDesc()
        Method needed for error message generation
      • getCopyBuffer

        protected final char[] getCopyBuffer()
      • getCopyBuffer

        protected final char[] getCopyBuffer​(int minLen)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object