com.ctc.wstx.sw
Class BaseStreamWriter

java.lang.Object
  extended bycom.ctc.wstx.sw.BaseStreamWriter
All Implemented Interfaces:
OutputConfigFlags, javax.xml.stream.XMLStreamConstants, javax.xml.stream.XMLStreamWriter, XMLStreamWriter2
Direct Known Subclasses:
BaseNsStreamWriter, NonNsStreamWriter

public abstract class BaseStreamWriter
extends java.lang.Object
implements XMLStreamWriter2, javax.xml.stream.XMLStreamConstants, 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 Summary
protected static char CHAR_SPACE
           
protected static java.lang.String DEFAULT_ENCODING
          Default encoding we assume, if nothing is passed explicitly.
protected static char DEFAULT_QUOTE_CHAR
           
protected  boolean mAnyOutput
          Flag that is set to true first time something has been output.
protected  AttributeCollector mAttrCollector
           
protected  java.io.Writer mAttrValueWriter
          Lazy-constructed writer that will properly escape characters of attribute values that need escaping ('<', '&', '"').
protected  boolean mCfgAutomaticEmptyElems
           
protected  boolean mCfgCDataAsText
           
protected  boolean mCfgCopyDefaultAttrs
           
protected  boolean mCheckAttr
           
protected  boolean mCheckContent
           
protected  boolean mCheckNames
           
protected  boolean mCheckStructure
           
protected  WriterConfig mConfig
           
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).
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.
protected  boolean mFixContent
           
protected  InputElementStack mInputElemStack
           
protected  XMLStreamReader2 mLastReader
          Reader that was last used for copy-through operation; used in conjunction with the other copy-through state variables.
protected  StreamReaderImpl mLastReaderImpl
           
protected  boolean mNsAware
           
protected  boolean mStartElementOpen
          Flag that is set during time that a start element is "open", ie.
protected  int mState
           
protected  java.io.Writer mTextWriter
          Lazy-constructed writer that will properly escape characters of text content that need escaping ('<', '&' etc).
protected  java.io.Writer mWriter
          Actual physical writer to output serialized XML content to
protected static int STATE_EPILOG
           
protected static int STATE_PROLOG
           
protected static int STATE_TREE
           
 
Fields inherited from interface javax.xml.stream.XMLStreamConstants
ATTRIBUTE, CDATA, CHARACTERS, COMMENT, DTD, END_DOCUMENT, END_ELEMENT, ENTITY_DECLARATION, ENTITY_REFERENCE, NAMESPACE, NOTATION_DECLARATION, PROCESSING_INSTRUCTION, SPACE, START_DOCUMENT, START_ELEMENT
 
Fields inherited from interface com.ctc.wstx.cfg.OutputConfigFlags
CFG_AUTOMATIC_EMPTY_ELEMS, CFG_AUTOMATIC_NS, CFG_COPY_DEFAULT_ATTRS, CFG_ENABLE_NS, CFG_FIX_CONTENT, CFG_OUTPUT_CDATA_AS_TEXT, CFG_VALIDATE_ATTR, CFG_VALIDATE_CONTENT, CFG_VALIDATE_NAMES, CFG_VALIDATE_STRUCTURE
 
Constructor Summary
protected BaseStreamWriter(java.io.Writer w, java.lang.String enc, WriterConfig cfg)
           
 
Method Summary
 void close()
           
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.
protected  java.io.Writer constructAttributeValueWriter()
           
protected  java.io.Writer constructTextWriter()
           
 void copyEventFromReader(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 doWriteStartDocument(java.lang.String version, java.lang.String encoding, java.lang.String standAlone)
           
 void flush()
           
 void flushStream()
           
 java.lang.Object getFeature(java.lang.String name)
           
abstract  javax.xml.namespace.NamespaceContext getNamespaceContext()
           
abstract  java.lang.String getPrefix(java.lang.String uri)
           
 java.lang.Object getProperty(java.lang.String name)
           
 java.io.Writer getWriter()
          Method needed by WstxEventWriter, when it needs/wants to do direct output, without calling methods in this class (not often).
 boolean inPrologOrEpilog()
           
 void safeFlushStream()
           
abstract  void setDefaultNamespace(java.lang.String uri)
           
 void setFeature(java.lang.String name, java.lang.Object value)
           
abstract  void setNamespaceContext(javax.xml.namespace.NamespaceContext context)
           
abstract  void setPrefix(java.lang.String prefix, java.lang.String uri)
           
protected static void throwFromIOE(java.io.IOException ioe)
           
protected static void throwIllegalArg(java.lang.String msg)
           
protected static void throwIllegalArg(java.lang.String format, java.lang.Object arg)
           
protected static void throwOutputError(java.lang.String msg)
           
protected static void throwOutputError(java.lang.String format, java.lang.Object arg)
           
protected  int verifyCDataContent(char[] c, int start, int end)
           
protected  int verifyCDataContent(java.lang.String content)
           
protected  int verifyCommentContent(java.lang.String content)
           
static void verifyNameValidity(java.lang.String name, boolean nsAware)
          Method called to verify that the name is a legal XML name.
protected  void verifyWriteDTD()
           
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[] c, int start, int len)
           
 void writeCData(java.lang.String data)
           
 void writeCharacters(char[] text, int start, int len)
           
 void writeCharacters(javax.xml.stream.events.Characters ch)
          Method called by WstxEventWriter (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 writeCharacters(java.lang.String text)
           
 void writeComment(java.lang.String data)
           
abstract  void writeDefaultNamespace(java.lang.String nsURI)
           
 void writeDTD(DTDInfo info)
           
 void writeDTD(java.lang.String dtd)
           
 void writeDTD(java.lang.String rootName, java.lang.String systemId, java.lang.String publicId, java.lang.String internalSubset)
           
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 WstxEventWriter (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()
          Method similar to writeEndElement(), but that will always write the full end element, instead of empty element.
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 offset, int length)
          Method that writes specified content as is, without encoding or deciphering it in any way.
 void writeRaw(java.lang.String text)
          Method that writes specified content as is, without encoding or deciphering it in any way.
protected  void writeSegmentedCData(char[] c, int start, int len, int index)
           
protected  void writeSegmentedCData(java.lang.String content, int index)
           
protected  void writeSegmentedComment(java.lang.String content, int index)
           
 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(javax.xml.stream.events.StartElement elem)
          Convenience method needed by WstxEventWriter, to use when writing a start element, and possibly its attributes and namespace declarations.
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)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATE_PROLOG

protected static final int STATE_PROLOG
See Also:
Constant Field Values

STATE_TREE

protected static final int STATE_TREE
See Also:
Constant Field Values

STATE_EPILOG

protected static final int STATE_EPILOG
See Also:
Constant Field Values

CHAR_SPACE

protected static final char CHAR_SPACE
See Also:
Constant Field Values

DEFAULT_QUOTE_CHAR

protected static final char DEFAULT_QUOTE_CHAR
See Also:
Constant Field Values

DEFAULT_ENCODING

protected static final java.lang.String DEFAULT_ENCODING
Default encoding we assume, if nothing is passed explicitly.

See Also:
Constant Field Values

mWriter

protected final java.io.Writer mWriter
Actual physical writer to output serialized XML content to


mTextWriter

protected java.io.Writer mTextWriter
Lazy-constructed writer that will properly escape characters of text content that need escaping ('<', '&' etc). It will be created when needed for the first time. Instances are usually chained to use mWriter for actual outputting.


mAttrValueWriter

protected java.io.Writer mAttrValueWriter
Lazy-constructed writer that will properly escape characters of attribute values that need escaping ('<', '&', '"'). It will be created when needed for the first time. Instances are usually chained to use mWriter for actual outputting.


mConfig

protected final WriterConfig mConfig

mNsAware

protected final boolean mNsAware

mCfgAutomaticEmptyElems

protected final boolean mCfgAutomaticEmptyElems

mCfgCDataAsText

protected final boolean mCfgCDataAsText

mCfgCopyDefaultAttrs

protected final boolean mCfgCopyDefaultAttrs

mCheckStructure

protected final boolean mCheckStructure

mCheckContent

protected final boolean mCheckContent

mCheckAttr

protected final boolean mCheckAttr

mCheckNames

protected final boolean mCheckNames

mFixContent

protected final boolean mFixContent

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).


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.


mLastReader

protected XMLStreamReader2 mLastReader
Reader that was last used for copy-through operation; used in conjunction with the other copy-through state variables.


mLastReaderImpl

protected StreamReaderImpl mLastReaderImpl

mAttrCollector

protected AttributeCollector mAttrCollector

mInputElemStack

protected InputElementStack mInputElemStack
Constructor Detail

BaseStreamWriter

protected BaseStreamWriter(java.io.Writer w,
                           java.lang.String enc,
                           WriterConfig cfg)
Method Detail

constructAttributeValueWriter

protected java.io.Writer constructAttributeValueWriter()
                                                throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException

constructTextWriter

protected java.io.Writer constructTextWriter()
                                      throws java.io.UnsupportedEncodingException
Throws:
java.io.UnsupportedEncodingException

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)
Specified by:
setNamespaceContext in interface javax.xml.stream.XMLStreamWriter

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

getFeature

public java.lang.Object getFeature(java.lang.String name)
Specified by:
getFeature in interface XMLStreamWriter2
Parameters:
name - Name of the feature of which value to get
Returns:
Value of the feature (possibly null), if supported; null otherwise

setFeature

public void setFeature(java.lang.String name,
                       java.lang.Object value)
Specified by:
setFeature in interface XMLStreamWriter2
Parameters:
name - Name of the feature to set
value - Value to set feature to.

writeCData

public void writeCData(char[] c,
                       int start,
                       int len)
                throws javax.xml.stream.XMLStreamException
Specified by:
writeCData in interface XMLStreamWriter2
Throws:
javax.xml.stream.XMLStreamException

writeDTD

public void writeDTD(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 XMLStreamWriter2
Throws:
javax.xml.stream.XMLStreamException

writeFullEndElement

public abstract void writeFullEndElement()
                                  throws javax.xml.stream.XMLStreamException
Description copied from interface: XMLStreamWriter2
Method similar to XMLStreamWriter.writeEndElement(), but that will always write the full end element, instead of empty element. This only matters for cases where the element itself has no content, and if writer is allowed to write empty elements when it encounters such start/end element write pairs.

Specified by:
writeFullEndElement in interface XMLStreamWriter2
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 XMLStreamWriter2
Throws:
javax.xml.stream.XMLStreamException

writeRaw

public void writeRaw(java.lang.String text)
              throws javax.xml.stream.XMLStreamException
Description copied from interface: XMLStreamWriter2
Method that writes specified content as is, without encoding or deciphering it in any way. It will not update state of the writer (except by possibly flushing output of previous writes, like finishing a start element), nor be validated in any way. As such, care must be taken, if this method is used.

Method is usually used when encapsulating output from another writer as a sub-tree, or when passing through XML fragments.

Specified by:
writeRaw in interface XMLStreamWriter2
Throws:
javax.xml.stream.XMLStreamException

writeRaw

public void writeRaw(char[] text,
                     int offset,
                     int length)
              throws javax.xml.stream.XMLStreamException
Description copied from interface: XMLStreamWriter2
Method that writes specified content as is, without encoding or deciphering it in any way. It will not update state of the writer (except by possibly flushing output of previous writes, like finishing a start element), nor be validated in any way. As such, care must be taken, if this method is used.

Method is usually used when encapsulating output from another writer as a sub-tree, or when passing through XML fragments.

Specified by:
writeRaw in interface XMLStreamWriter2
Throws:
javax.xml.stream.XMLStreamException

copyEventFromReader

public void copyEventFromReader(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 XMLStreamWriter2
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

getWriter

public java.io.Writer getWriter()
Method needed by WstxEventWriter, when it needs/wants to do direct output, without calling methods in this class (not often).


writeStartElement

public abstract void writeStartElement(javax.xml.stream.events.StartElement elem)
                                throws javax.xml.stream.XMLStreamException
Convenience method needed by WstxEventWriter, 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 WstxEventWriter (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 WstxEventWriter (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).

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

public boolean inPrologOrEpilog()

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

flushStream

public void flushStream()
                 throws java.io.IOException
Throws:
java.io.IOException

safeFlushStream

public void safeFlushStream()
                     throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

verifyNameValidity

public static void verifyNameValidity(java.lang.String name,
                                      boolean nsAware)
Method called to verify that the name is a legal XML name.


verifyWriteDTD

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

verifyCDataContent

protected int verifyCDataContent(java.lang.String content)
Returns:
Index at which a problem was found, if any; -1 if there's no problem.

verifyCDataContent

protected int verifyCDataContent(char[] c,
                                 int start,
                                 int end)

verifyCommentContent

protected int verifyCommentContent(java.lang.String content)

writeSegmentedCData

protected void writeSegmentedCData(java.lang.String content,
                                   int index)
                            throws java.io.IOException
Throws:
java.io.IOException

writeSegmentedCData

protected void writeSegmentedCData(char[] c,
                                   int start,
                                   int len,
                                   int index)
                            throws java.io.IOException
Throws:
java.io.IOException

writeSegmentedComment

protected void writeSegmentedComment(java.lang.String content,
                                     int index)
                              throws java.io.IOException
Throws:
java.io.IOException

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

throwFromIOE

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

throwIllegalArg

protected static void throwIllegalArg(java.lang.String msg)
                               throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException

throwIllegalArg

protected static void throwIllegalArg(java.lang.String format,
                                      java.lang.Object arg)
                               throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException