com.sun.xml.stream.buffer.stax
Class StreamWriterBufferCreator

java.lang.Object
  extended by com.sun.xml.stream.buffer.AbstractCreatorProcessor
      extended by com.sun.xml.stream.buffer.AbstractCreator
          extended by com.sun.xml.stream.buffer.stax.StreamWriterBufferCreator
All Implemented Interfaces:
XMLStreamWriter, XMLStreamWriterEx

public class StreamWriterBufferCreator
extends AbstractCreator
implements XMLStreamWriterEx

XMLStreamWriter that fills MutableXMLStreamBuffer.

TODO: need to retain all attributes/namespaces and then store all namespaces before the attributes. Currently it is necessary for the caller to ensure all namespaces are written before attributes and the caller must not intermix calls to the writeNamespace and writeAttribute methods.


Field Summary
protected  List<String> attributeValuePrefixes
           
 
Fields inherited from class com.sun.xml.stream.buffer.AbstractCreator
_buffer
 
Fields inherited from class com.sun.xml.stream.buffer.AbstractCreatorProcessor
_contentCharactersBuffer, _contentCharactersBufferPtr, _contentObjects, _contentObjectsPtr, _currentContentCharactersBufferFragment, _currentContentObjectFragment, _currentStructureFragment, _currentStructureStringFragment, _structure, _structurePtr, _structureStrings, _structureStringsPtr, CHAR_ARRAY_LENGTH_MEDIUM, CHAR_ARRAY_LENGTH_MEDIUM_SIZE, CHAR_ARRAY_LENGTH_SMALL, CHAR_ARRAY_LENGTH_SMALL_SIZE, CONTENT_TYPE_CHAR_ARRAY, CONTENT_TYPE_CHAR_ARRAY_COPY, CONTENT_TYPE_OBJECT, CONTENT_TYPE_STRING, FLAG_DOCUMENT_FRAGMENT, FLAG_PREFIX, FLAG_QUALIFIED_NAME, FLAG_URI, T_ATTRIBUTE, T_ATTRIBUTE_LN, T_ATTRIBUTE_LN_OBJECT, T_ATTRIBUTE_P_U_LN, T_ATTRIBUTE_P_U_LN_OBJECT, T_ATTRIBUTE_U_LN, T_ATTRIBUTE_U_LN_OBJECT, T_ATTRIBUTE_U_LN_QN, T_ATTRIBUTE_U_LN_QN_OBJECT, T_COMMENT, T_COMMENT_AS_CHAR_ARRAY, T_COMMENT_AS_CHAR_ARRAY_COPY, T_COMMENT_AS_CHAR_ARRAY_MEDIUM, T_COMMENT_AS_CHAR_ARRAY_SMALL, T_COMMENT_AS_STRING, T_DOCUMENT, T_DOCUMENT_FRAGMENT, T_ELEMENT, T_ELEMENT_LN, T_ELEMENT_P_U_LN, T_ELEMENT_U_LN, T_ELEMENT_U_LN_QN, T_END, T_END_OF_BUFFER, T_NAMESPACE_ATTRIBUTE, T_NAMESPACE_ATTRIBUTE_P, T_NAMESPACE_ATTRIBUTE_P_U, T_NAMESPACE_ATTRIBUTE_U, T_PROCESSING_INSTRUCTION, T_TEXT, T_TEXT_AS_CHAR_ARRAY, T_TEXT_AS_CHAR_ARRAY_COPY, T_TEXT_AS_CHAR_ARRAY_MEDIUM, T_TEXT_AS_CHAR_ARRAY_SMALL, T_TEXT_AS_OBJECT, T_TEXT_AS_STRING, T_UNEXPANDED_ENTITY_REFERENCE, TYPE_MASK, VALUE_TYPE_OBJECT, VALUE_TYPE_STRING
 
Constructor Summary
StreamWriterBufferCreator()
           
StreamWriterBufferCreator(MutableXMLStreamBuffer buffer)
           
 
Method Summary
 void close()
           
 void flush()
           
 List getAttributeValuePrefixes()
           
 NamespaceContextEx getNamespaceContext()
          
 String getPrefix(String namespaceURI)
           
 Object getProperty(String str)
           
 boolean isCheckAttributeValue()
           
 void setCheckAttributeValue(boolean value)
           
 void setDefaultNamespace(String namespaceURI)
           
 void setNamespaceContext(NamespaceContext namespaceContext)
           
 void setPrefix(String prefix, String namespaceURI)
           
protected  void storeAttribute(String prefix, String uri, String localName, String type, String value)
           
protected  void storeNamespaceAttribute(String prefix, String uri)
           
protected  void storeProcessingInstruction(String target, String data)
           
protected  void storeQualifiedName(int item, String prefix, String uri, String localName)
           
 void writeAttribute(String localName, String value)
           
 void writeAttribute(String namespaceURI, String localName, String value)
           
 void writeAttribute(String prefix, String namespaceURI, String localName, String value)
           
 void writeBinary(byte[] bytes, int offset, int length, String endpointURL)
          Write the binary data.
 void writeBinary(DataHandler dataHandler)
          Writes the binary data.
 OutputStream writeBinary(String endpointURL)
          Writes the binary data.
 void writeCData(String data)
           
 void writeCharacters(char[] buf, int start, int len)
           
 void writeCharacters(String charData)
           
 void writeComment(String str)
           
 void writeDefaultNamespace(String namespaceURI)
           
 void writeDTD(String str)
           
 void writeEmptyElement(String localName)
           
 void writeEmptyElement(String namespaceURI, String localName)
           
 void writeEmptyElement(String prefix, String localName, String namespaceURI)
           
 void writeEndDocument()
           
 void writeEndElement()
           
 void writeEntityRef(String str)
           
 void writeNamespace(String prefix, String namespaceURI)
           
 void writePCDATA(CharSequence charSequence)
          Writes like XMLStreamWriter.writeCharacters(String) but hides actual data format.
 void writeProcessingInstruction(String target)
           
 void writeProcessingInstruction(String target, String data)
           
 void writeStartDocument()
           
 void writeStartDocument(String version)
           
 void writeStartDocument(String encoding, String version)
           
 void writeStartElement(String localName)
           
 void writeStartElement(String namespaceURI, String localName)
           
 void writeStartElement(String prefix, String localName, String namespaceURI)
           
 
Methods inherited from class com.sun.xml.stream.buffer.AbstractCreator
createBuffer, getXMLStreamBuffer, increaseTreeCount, peekAtContentObject, resizeContentCharacters, resizeContentObjects, resizeStructure, resizeStructureStrings, setBuffer, setHasInternedStrings, setXMLStreamBuffer, storeContentCharacters, storeContentCharactersCopy, storeContentObject, storeContentString, storeStructure, storeStructureString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

attributeValuePrefixes

protected List<String> attributeValuePrefixes
Constructor Detail

StreamWriterBufferCreator

public StreamWriterBufferCreator()

StreamWriterBufferCreator

public StreamWriterBufferCreator(MutableXMLStreamBuffer buffer)
Method Detail

getProperty

public Object getProperty(String str)
                   throws IllegalArgumentException
Specified by:
getProperty in interface XMLStreamWriter
Throws:
IllegalArgumentException

close

public void close()
           throws XMLStreamException
Specified by:
close in interface XMLStreamWriter
Throws:
XMLStreamException

flush

public void flush()
           throws XMLStreamException
Specified by:
flush in interface XMLStreamWriter
Throws:
XMLStreamException

getNamespaceContext

public NamespaceContextEx getNamespaceContext()
Description copied from interface: XMLStreamWriterEx

Specified by:
getNamespaceContext in interface XMLStreamWriter
Specified by:
getNamespaceContext in interface XMLStreamWriterEx

setNamespaceContext

public void setNamespaceContext(NamespaceContext namespaceContext)
                         throws XMLStreamException
Specified by:
setNamespaceContext in interface XMLStreamWriter
Throws:
XMLStreamException

setDefaultNamespace

public void setDefaultNamespace(String namespaceURI)
                         throws XMLStreamException
Specified by:
setDefaultNamespace in interface XMLStreamWriter
Throws:
XMLStreamException

setPrefix

public void setPrefix(String prefix,
                      String namespaceURI)
               throws XMLStreamException
Specified by:
setPrefix in interface XMLStreamWriter
Throws:
XMLStreamException

getPrefix

public String getPrefix(String namespaceURI)
                 throws XMLStreamException
Specified by:
getPrefix in interface XMLStreamWriter
Throws:
XMLStreamException

writeStartDocument

public void writeStartDocument()
                        throws XMLStreamException
Specified by:
writeStartDocument in interface XMLStreamWriter
Throws:
XMLStreamException

writeStartDocument

public void writeStartDocument(String version)
                        throws XMLStreamException
Specified by:
writeStartDocument in interface XMLStreamWriter
Throws:
XMLStreamException

writeStartDocument

public void writeStartDocument(String encoding,
                               String version)
                        throws XMLStreamException
Specified by:
writeStartDocument in interface XMLStreamWriter
Throws:
XMLStreamException

writeEndDocument

public void writeEndDocument()
                      throws XMLStreamException
Specified by:
writeEndDocument in interface XMLStreamWriter
Throws:
XMLStreamException

writeStartElement

public void writeStartElement(String localName)
                       throws XMLStreamException
Specified by:
writeStartElement in interface XMLStreamWriter
Throws:
XMLStreamException

writeStartElement

public void writeStartElement(String namespaceURI,
                              String localName)
                       throws XMLStreamException
Specified by:
writeStartElement in interface XMLStreamWriter
Throws:
XMLStreamException

writeStartElement

public void writeStartElement(String prefix,
                              String localName,
                              String namespaceURI)
                       throws XMLStreamException
Specified by:
writeStartElement in interface XMLStreamWriter
Throws:
XMLStreamException

writeEmptyElement

public void writeEmptyElement(String localName)
                       throws XMLStreamException
Specified by:
writeEmptyElement in interface XMLStreamWriter
Throws:
XMLStreamException

writeEmptyElement

public void writeEmptyElement(String namespaceURI,
                              String localName)
                       throws XMLStreamException
Specified by:
writeEmptyElement in interface XMLStreamWriter
Throws:
XMLStreamException

writeEmptyElement

public void writeEmptyElement(String prefix,
                              String localName,
                              String namespaceURI)
                       throws XMLStreamException
Specified by:
writeEmptyElement in interface XMLStreamWriter
Throws:
XMLStreamException

writeEndElement

public void writeEndElement()
                     throws XMLStreamException
Specified by:
writeEndElement in interface XMLStreamWriter
Throws:
XMLStreamException

writeDefaultNamespace

public void writeDefaultNamespace(String namespaceURI)
                           throws XMLStreamException
Specified by:
writeDefaultNamespace in interface XMLStreamWriter
Throws:
XMLStreamException

writeNamespace

public void writeNamespace(String prefix,
                           String namespaceURI)
                    throws XMLStreamException
Specified by:
writeNamespace in interface XMLStreamWriter
Throws:
XMLStreamException

writeAttribute

public void writeAttribute(String localName,
                           String value)
                    throws XMLStreamException
Specified by:
writeAttribute in interface XMLStreamWriter
Throws:
XMLStreamException

writeAttribute

public void writeAttribute(String namespaceURI,
                           String localName,
                           String value)
                    throws XMLStreamException
Specified by:
writeAttribute in interface XMLStreamWriter
Throws:
XMLStreamException

writeAttribute

public void writeAttribute(String prefix,
                           String namespaceURI,
                           String localName,
                           String value)
                    throws XMLStreamException
Specified by:
writeAttribute in interface XMLStreamWriter
Throws:
XMLStreamException

writeCData

public void writeCData(String data)
                throws XMLStreamException
Specified by:
writeCData in interface XMLStreamWriter
Throws:
XMLStreamException

writeCharacters

public void writeCharacters(String charData)
                     throws XMLStreamException
Specified by:
writeCharacters in interface XMLStreamWriter
Throws:
XMLStreamException

writeCharacters

public void writeCharacters(char[] buf,
                            int start,
                            int len)
                     throws XMLStreamException
Specified by:
writeCharacters in interface XMLStreamWriter
Throws:
XMLStreamException

writeComment

public void writeComment(String str)
                  throws XMLStreamException
Specified by:
writeComment in interface XMLStreamWriter
Throws:
XMLStreamException

writeDTD

public void writeDTD(String str)
              throws XMLStreamException
Specified by:
writeDTD in interface XMLStreamWriter
Throws:
XMLStreamException

writeEntityRef

public void writeEntityRef(String str)
                    throws XMLStreamException
Specified by:
writeEntityRef in interface XMLStreamWriter
Throws:
XMLStreamException

writeProcessingInstruction

public void writeProcessingInstruction(String target)
                                throws XMLStreamException
Specified by:
writeProcessingInstruction in interface XMLStreamWriter
Throws:
XMLStreamException

writeProcessingInstruction

public void writeProcessingInstruction(String target,
                                       String data)
                                throws XMLStreamException
Specified by:
writeProcessingInstruction in interface XMLStreamWriter
Throws:
XMLStreamException

writePCDATA

public void writePCDATA(CharSequence charSequence)
                 throws XMLStreamException
Description copied from interface: XMLStreamWriterEx
Writes like XMLStreamWriter.writeCharacters(String) but hides actual data format.

Specified by:
writePCDATA in interface XMLStreamWriterEx
Parameters:
charSequence - The CharSequence that represents the character infoset items to be written.

The CharSequence is normally a String, but can be any other CharSequence implementation. For binary data, however, use of Base64Data is recommended (so that the consumer interested in seeing it as binary data may take advantage of mor efficient data representation.)

Throws:
XMLStreamException

writeBinary

public void writeBinary(byte[] bytes,
                        int offset,
                        int length,
                        String endpointURL)
                 throws XMLStreamException
Description copied from interface: XMLStreamWriterEx
Write the binary data.

Conceptually (infoset-wise), this produces the base64-encoded binary data on the output. But this allows implementations like FastInfoset or XOP to do the smart thing.

The use of this method has some restriction to support XOP. Namely, this method must be invoked as a sole content of an element.

(data,start,len) triplet identifies the binary data to be written. After the method invocation, the callee owns the buffer.

Specified by:
writeBinary in interface XMLStreamWriterEx
endpointURL - this mandatory parameter identifies the MIME type of the binary data. If the MIME type isn't known by the caller, "application/octet-stream" can be always used to indicate "I don't know." Never null.
Throws:
XMLStreamException

writeBinary

public void writeBinary(DataHandler dataHandler)
                 throws XMLStreamException
Description copied from interface: XMLStreamWriterEx
Writes the binary data.

This method works like the XMLStreamWriterEx.writeBinary(byte[], int, int, String) method, except that it takes the binary data in the form of DataHandler, which contains a MIME type (DataHandler.getContentType() as well as the payload DataHandler.getInputStream().

Specified by:
writeBinary in interface XMLStreamWriterEx
Parameters:
dataHandler - always non-null. After this method call, the callee owns the data handler.
Throws:
XMLStreamException

writeBinary

public OutputStream writeBinary(String endpointURL)
                         throws XMLStreamException
Description copied from interface: XMLStreamWriterEx
Writes the binary data.

This version of the writeBinary method allows the caller to produce the binary data by writing it to OutputStream.

It is the caller's responsibility to write and close a stream before it invokes any other methods on XMLStreamWriter. TODO: experimental. appreciate feedback

Specified by:
writeBinary in interface XMLStreamWriterEx
Parameters:
endpointURL - See the content-type parameter of XMLStreamWriterEx.writeBinary(byte[], int, int, String). Must not be null.
Returns:
always return a non-null OutputStream.
Throws:
XMLStreamException

storeQualifiedName

protected void storeQualifiedName(int item,
                                  String prefix,
                                  String uri,
                                  String localName)

storeNamespaceAttribute

protected final void storeNamespaceAttribute(String prefix,
                                             String uri)

storeAttribute

protected final void storeAttribute(String prefix,
                                    String uri,
                                    String localName,
                                    String type,
                                    String value)

getAttributeValuePrefixes

public final List getAttributeValuePrefixes()

storeProcessingInstruction

protected final void storeProcessingInstruction(String target,
                                                String data)

isCheckAttributeValue

public final boolean isCheckAttributeValue()

setCheckAttributeValue

public final void setCheckAttributeValue(boolean value)


Copyright © 2005-2015 Oracle Corporation. All Rights Reserved.