Class StreamWriterBufferCreator
- java.lang.Object
-
- com.sun.xml.stream.buffer.AbstractCreatorProcessor
-
- com.sun.xml.stream.buffer.AbstractCreator
-
- com.sun.xml.stream.buffer.stax.StreamWriterBufferCreator
-
- All Implemented Interfaces:
XMLStreamWriter,XMLStreamWriterEx
public class StreamWriterBufferCreator extends AbstractCreator implements XMLStreamWriterEx
XMLStreamWriterthat fillsMutableXMLStreamBuffer.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
Fields Modifier and Type Field Description 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
Constructors Constructor Description StreamWriterBufferCreator()StreamWriterBufferCreator(MutableXMLStreamBuffer buffer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidflush()ListgetAttributeValuePrefixes()NamespaceContextExgetNamespaceContext()StringgetPrefix(String namespaceURI)ObjectgetProperty(String str)booleanisCheckAttributeValue()voidsetCheckAttributeValue(boolean value)voidsetDefaultNamespace(String namespaceURI)voidsetNamespaceContext(NamespaceContext namespaceContext)voidsetPrefix(String prefix, String namespaceURI)protected voidstoreAttribute(String prefix, String uri, String localName, String type, String value)protected voidstoreNamespaceAttribute(String prefix, String uri)protected voidstoreProcessingInstruction(String target, String data)protected voidstoreQualifiedName(int item, String prefix, String uri, String localName)voidwriteAttribute(String localName, String value)voidwriteAttribute(String namespaceURI, String localName, String value)voidwriteAttribute(String prefix, String namespaceURI, String localName, String value)voidwriteBinary(byte[] bytes, int offset, int length, String endpointURL)Write the binary data.voidwriteBinary(jakarta.activation.DataHandler dataHandler)Writes the binary data.OutputStreamwriteBinary(String endpointURL)Writes the binary data.voidwriteCData(String data)voidwriteCharacters(char[] buf, int start, int len)voidwriteCharacters(String charData)voidwriteComment(String str)voidwriteDefaultNamespace(String namespaceURI)voidwriteDTD(String str)voidwriteEmptyElement(String localName)voidwriteEmptyElement(String namespaceURI, String localName)voidwriteEmptyElement(String prefix, String localName, String namespaceURI)voidwriteEndDocument()voidwriteEndElement()voidwriteEntityRef(String str)voidwriteNamespace(String prefix, String namespaceURI)voidwritePCDATA(CharSequence charSequence)Writes likeXMLStreamWriter.writeCharacters(String)but hides actual data format.voidwriteProcessingInstruction(String target)voidwriteProcessingInstruction(String target, String data)voidwriteStartDocument()voidwriteStartDocument(String version)voidwriteStartDocument(String encoding, String version)voidwriteStartElement(String localName)voidwriteStartElement(String namespaceURI, String localName)voidwriteStartElement(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
-
-
-
-
Constructor Detail
-
StreamWriterBufferCreator
public StreamWriterBufferCreator()
-
StreamWriterBufferCreator
public StreamWriterBufferCreator(MutableXMLStreamBuffer buffer)
-
-
Method Detail
-
getProperty
public Object getProperty(String str) throws IllegalArgumentException
- Specified by:
getPropertyin interfaceXMLStreamWriter- Throws:
IllegalArgumentException
-
close
public void close() throws XMLStreamException- Specified by:
closein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
flush
public void flush() throws XMLStreamException- Specified by:
flushin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
getNamespaceContext
public NamespaceContextEx getNamespaceContext()
Description copied from interface:XMLStreamWriterEx- Specified by:
getNamespaceContextin interfaceXMLStreamWriter- Specified by:
getNamespaceContextin interfaceXMLStreamWriterEx
-
setNamespaceContext
public void setNamespaceContext(NamespaceContext namespaceContext) throws XMLStreamException
- Specified by:
setNamespaceContextin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
setDefaultNamespace
public void setDefaultNamespace(String namespaceURI) throws XMLStreamException
- Specified by:
setDefaultNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
setPrefix
public void setPrefix(String prefix, String namespaceURI) throws XMLStreamException
- Specified by:
setPrefixin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
getPrefix
public String getPrefix(String namespaceURI) throws XMLStreamException
- Specified by:
getPrefixin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
public void writeStartDocument() throws XMLStreamException- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
public void writeStartDocument(String version) throws XMLStreamException
- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartDocument
public void writeStartDocument(String encoding, String version) throws XMLStreamException
- Specified by:
writeStartDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEndDocument
public void writeEndDocument() throws XMLStreamException- Specified by:
writeEndDocumentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartElement
public void writeStartElement(String localName) throws XMLStreamException
- Specified by:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartElement
public void writeStartElement(String namespaceURI, String localName) throws XMLStreamException
- Specified by:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeStartElement
public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException
- Specified by:
writeStartElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEmptyElement
public void writeEmptyElement(String localName) throws XMLStreamException
- Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEmptyElement
public void writeEmptyElement(String namespaceURI, String localName) throws XMLStreamException
- Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEmptyElement
public void writeEmptyElement(String prefix, String localName, String namespaceURI) throws XMLStreamException
- Specified by:
writeEmptyElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEndElement
public void writeEndElement() throws XMLStreamException- Specified by:
writeEndElementin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeDefaultNamespace
public void writeDefaultNamespace(String namespaceURI) throws XMLStreamException
- Specified by:
writeDefaultNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeNamespace
public void writeNamespace(String prefix, String namespaceURI) throws XMLStreamException
- Specified by:
writeNamespacein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
public void writeAttribute(String localName, String value) throws XMLStreamException
- Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
public void writeAttribute(String namespaceURI, String localName, String value) throws XMLStreamException
- Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeAttribute
public void writeAttribute(String prefix, String namespaceURI, String localName, String value) throws XMLStreamException
- Specified by:
writeAttributein interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCData
public void writeCData(String data) throws XMLStreamException
- Specified by:
writeCDatain interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCharacters
public void writeCharacters(String charData) throws XMLStreamException
- Specified by:
writeCharactersin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeCharacters
public void writeCharacters(char[] buf, int start, int len) throws XMLStreamException- Specified by:
writeCharactersin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeComment
public void writeComment(String str) throws XMLStreamException
- Specified by:
writeCommentin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeDTD
public void writeDTD(String str) throws XMLStreamException
- Specified by:
writeDTDin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeEntityRef
public void writeEntityRef(String str) throws XMLStreamException
- Specified by:
writeEntityRefin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeProcessingInstruction
public void writeProcessingInstruction(String target) throws XMLStreamException
- Specified by:
writeProcessingInstructionin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writeProcessingInstruction
public void writeProcessingInstruction(String target, String data) throws XMLStreamException
- Specified by:
writeProcessingInstructionin interfaceXMLStreamWriter- Throws:
XMLStreamException
-
writePCDATA
public void writePCDATA(CharSequence charSequence) throws XMLStreamException
Description copied from interface:XMLStreamWriterExWrites likeXMLStreamWriter.writeCharacters(String)but hides actual data format.- Specified by:
writePCDATAin interfaceXMLStreamWriterEx- Parameters:
charSequence- TheCharSequencethat represents the character infoset items to be written.The
CharSequenceis normally aString, but can be any otherCharSequenceimplementation. For binary data, however, use ofBase64Datais 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 XMLStreamExceptionDescription copied from interface:XMLStreamWriterExWrite 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:
writeBinaryin interfaceXMLStreamWriterExendpointURL- 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(jakarta.activation.DataHandler dataHandler) throws XMLStreamExceptionDescription copied from interface:XMLStreamWriterExWrites 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 ofDataHandler, which contains a MIME type (DataHandler.getContentType()as well as the payloadDataHandler.getInputStream().- Specified by:
writeBinaryin interfaceXMLStreamWriterEx- 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:XMLStreamWriterExWrites 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:
writeBinaryin interfaceXMLStreamWriterEx- Parameters:
endpointURL- See the content-type parameter ofXMLStreamWriterEx.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)
-
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)
-
-