public interface XMLStreamWriterEx extends XMLStreamWriter
XMLStreamWriter
extended to support XOP.
Some infoset serializer (such as XOP encoder, FastInfoset) uses a format that can represent binary data more efficiently than base64 encoding. Such infoset serializer may choose to implement this interface, to allow the caller to pass in binary data more efficiently without first converting it to binary data.
Callers capable of using this interface can see if the serializer supports
it by simply downcasting XMLStreamWriter
to XMLStreamWriterEx
.
XMLStreamReaderEx
Modifier and Type | Method and Description |
---|---|
NamespaceContextEx |
getNamespaceContext() |
void |
writeBinary(byte[] data,
int start,
int len,
String contentType)
Write the binary data.
|
void |
writeBinary(DataHandler data)
Writes the binary data.
|
OutputStream |
writeBinary(String contentType)
Writes the binary data.
|
void |
writePCDATA(CharSequence data)
Writes like
XMLStreamWriter.writeCharacters(String) but hides
actual data format. |
close, flush, 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
void writeBinary(byte[] data, int start, int len, String contentType) throws XMLStreamException
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.
contentType
- 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.XMLStreamException
void writeBinary(DataHandler data) throws XMLStreamException
This method works like the 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()
.
data
- always non-null. After this method call, the callee owns the data handler.XMLStreamException
OutputStream writeBinary(String contentType) throws XMLStreamException
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
contentType
- See the content-type parameter of
writeBinary(byte[], int, int, String)
. Must not be null.OutputStream
.XMLStreamException
void writePCDATA(CharSequence data) throws XMLStreamException
XMLStreamWriter.writeCharacters(String)
but hides
actual data format.data
- 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.)
XMLStreamException
NamespaceContextEx getNamespaceContext()
getNamespaceContext
in interface XMLStreamWriter
Copyright © 2006–2020. All rights reserved.