org.codehaus.stax2
Interface XMLStreamWriter2

All Superinterfaces:
javax.xml.stream.XMLStreamWriter
All Known Implementing Classes:
BaseStreamWriter

public interface XMLStreamWriter2
extends javax.xml.stream.XMLStreamWriter

Extended interface that implements functionality that is necessary to properly build event API on top of XMLStreamWriter, as well as to configure individual instances. It also adds limited number of methods that are important for efficient pass-through processing (such as one needed when routing SOAP-messages).


Method Summary
 void copyEventFromReader(XMLStreamReader2 r, boolean preserveEventData)
          Method that essentially copies event that the specified reader has just read.
 java.lang.Object getFeature(java.lang.String name)
           
 void setFeature(java.lang.String name, java.lang.Object value)
           
 void writeCData(char[] text, int start, int len)
           
 void writeDTD(java.lang.String rootName, java.lang.String systemId, java.lang.String publicId, java.lang.String internalSubset)
           
 void writeFullEndElement()
          Method similar to XMLStreamWriter.writeEndElement(), but that will always write the full end element, instead of empty element.
 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.
 void writeStartDocument(java.lang.String version, java.lang.String encoding, boolean standAlone)
           
 
Methods inherited from interface javax.xml.stream.XMLStreamWriter
close, flush, getNamespaceContext, getPrefix, getProperty, setDefaultNamespace, setNamespaceContext, setPrefix, writeAttribute, writeAttribute, writeAttribute, writeCData, writeCharacters, writeCharacters, writeComment, writeDefaultNamespace, writeDTD, writeEmptyElement, writeEmptyElement, writeEmptyElement, writeEndDocument, writeEndElement, writeEntityRef, writeNamespace, writeProcessingInstruction, writeProcessingInstruction, writeStartDocument, writeStartDocument, writeStartDocument, writeStartElement, writeStartElement, writeStartElement
 

Method Detail

getFeature

public java.lang.Object getFeature(java.lang.String name)
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)
Parameters:
name - Name of the feature to set
value - Value to set feature to.

writeCData

public void writeCData(char[] text,
                       int start,
                       int len)
                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
Throws:
javax.xml.stream.XMLStreamException

writeFullEndElement

public void writeFullEndElement()
                         throws javax.xml.stream.XMLStreamException
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.

Throws:
javax.xml.stream.XMLStreamException

writeStartDocument

public void writeStartDocument(java.lang.String version,
                               java.lang.String encoding,
                               boolean standAlone)
                        throws javax.xml.stream.XMLStreamException
Throws:
javax.xml.stream.XMLStreamException

writeRaw

public void writeRaw(java.lang.String text)
              throws javax.xml.stream.XMLStreamException
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.

Throws:
javax.xml.stream.XMLStreamException

writeRaw

public void writeRaw(char[] text,
                     int offset,
                     int length)
              throws javax.xml.stream.XMLStreamException
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.

Throws:
javax.xml.stream.XMLStreamException

copyEventFromReader

public void copyEventFromReader(XMLStreamReader2 r,
                                boolean preserveEventData)
                         throws javax.xml.stream.XMLStreamException
Method that essentially copies event that the specified reader has just read. This can be both more convenient (no need to worry about details) and more efficient than separately calling access methods of the reader and write methods of the writer, since writer may know more about reader than the application (and may be able to use non-public methods)

Parameters:
r - 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