Top Description Fields Constructors Methods
org.glassfish.jaxb.runtime.v2.runtime.unmarshaller

public final Class Base64Data

extends Pcdata
Class Inheritance
Imports
com.sun.istack.Nullable, org.glassfish.jaxb.runtime.DatatypeConverterImpl, org.glassfish.jaxb.runtime.v2.runtime.XMLSerializer, org.glassfish.jaxb.runtime.v2.runtime.output.Pcdata, .UTF8XmlOutput, org.glassfish.jaxb.runtime.v2.util.ByteArrayOutputStreamEx, jakarta.activation.DataHandler, .DataSource, javax.xml.stream.XMLStreamException, .XMLStreamWriter, java.io.ByteArrayInputStream, .IOException, .InputStream, .OutputStream

Fed to unmarshaller when the 'text' data is actually a virtual image of base64 encoding of the binary data transferred on the wire. Used for the MTOM support. This object is mutable and the owner of this object can reuse it with new data. Also used by the marshaller to write out the binary data that could be possibly attached.
Author
Kohsuke Kawaguchi, Martin Grebac
See Also
XmlVisitor#text(CharSequence), XMLSerializer#text(Pcdata, String)

Field Summary

Modifier and TypeField and Description
private byte[]
private DataHandler
private int
dataLen

Length of the valid data in data.

private String
mimeType

Optional MIME type of data.

Constructor Summary

AccessConstructor and Description
public
Base64Data()

Default constructor.

Method Summary

Modifier and TypeMethod and Description
public char
charAt(int index)

Implements java.lang.CharSequence.charAt.

Encode this binary data in the base64 encoding and returns the character at the specified position.

public byte[]
get()

Gets the raw data.

public DataHandler
getDataHandler()

Gets the raw data.

public int
public byte[]
getExact()

Gets the byte[] of the exact length.

public InputStream
getInputStream()

Gets the data as an InputStream.

public String
public boolean
hasData()

Returns false if this object only has DataHandler and therefore get() operation is likely going to be expensive.

public int
length()

Implements java.lang.CharSequence.length.

Gets the number of characters needed to represent this binary data in the base64 encoding.

public void
set(byte[] data, int
data[0] to data[len-1] are treated as the data.
len
,
String mimeType)

Fills in the data object by a portion of the byte[].

public void
set(byte[]
this buffer may be owned directly by the unmarshaleld JAXB object.
data
,
String mimeType)

Fills in the data object by the byte[] of the exact length.

public void
set(DataHandler data)

Fills in the data object by a DataHandler.

public CharSequence
subSequence(int start, int end)

Implements java.lang.CharSequence.subSequence.

Internally this is only used to split a text to a list, which doesn't happen that much for base64.

public String
toString()

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.output.Pcdata.toString.

Implements java.lang.CharSequence.toString.

Returns the base64 encoded string of this data.

public void
writeTo(char[] buf, int start)

Overrides org.glassfish.jaxb.runtime.v2.runtime.output.Pcdata.writeTo.

Writes itself to the character array.

public void
public void

Field Detail

databack to summary
private byte[] data
dataHandlerback to summary
private DataHandler dataHandler
dataLenback to summary
private int dataLen

Length of the valid data in data.

mimeTypeback to summary
private String mimeType

Optional MIME type of data. Unused when dataHandler is set. Use DataHandler#getContentType() in that case.

Annotations
@Nullable

Constructor Detail

Base64Databack to summary
public Base64Data()

Default constructor.

Method Detail

charAtback to summary
public char charAt(int index)

Implements java.lang.CharSequence.charAt.

Encode this binary data in the base64 encoding and returns the character at the specified position.

Annotations
@Override
@SuppressWarnings:deprecation
getback to summary
public byte[] get()

Gets the raw data. The size of the byte array maybe larger than the actual length.

getDataHandlerback to summary
public DataHandler getDataHandler()

Gets the raw data.

getDataLenback to summary
public int getDataLen()
getExactback to summary
public byte[] getExact()

Gets the byte[] of the exact length.

getInputStreamback to summary
public InputStream getInputStream() throws IOException

Gets the data as an InputStream.

getMimeTypeback to summary
public String getMimeType()
hasDataback to summary
public boolean hasData()

Returns false if this object only has DataHandler and therefore get() operation is likely going to be expensive.

lengthback to summary
public int length()

Implements java.lang.CharSequence.length.

Gets the number of characters needed to represent this binary data in the base64 encoding.

Annotations
@Override
setback to summary
public void set(byte[] data, int len, String mimeType)

Fills in the data object by a portion of the byte[].

Parameters
len:int

data[0] to data[len-1] are treated as the data.

setback to summary
public void set(byte[] data, String mimeType)

Fills in the data object by the byte[] of the exact length.

Parameters
data:byte[]

this buffer may be owned directly by the unmarshaleld JAXB object.

setback to summary
public void set(DataHandler data)

Fills in the data object by a DataHandler.

subSequenceback to summary
public CharSequence subSequence(int start, int end)

Implements java.lang.CharSequence.subSequence.

Internally this is only used to split a text to a list, which doesn't happen that much for base64. So this method should be smaller than faster.

Annotations
@Override
toStringback to summary
public String toString()

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.output.Pcdata.toString.

Implements java.lang.CharSequence.toString.

Returns the base64 encoded string of this data.

Annotations
@Override
@SuppressWarnings:deprecation
writeToback to summary
public void writeTo(char[] buf, int start)

Overrides org.glassfish.jaxb.runtime.v2.runtime.output.Pcdata.writeTo.

Doc from org.glassfish.jaxb.runtime.v2.runtime.output.Pcdata.writeTo.

Writes itself to the character array.

This method is used by most other XmlOutput. The default implementation involves in one extra char[] copying.

The caller must provide a big enough buffer that can hold enough characters returned by the length() method.

Annotations
@Override
@SuppressWarnings:deprecation
writeToback to summary
public void writeTo(UTF8XmlOutput output) throws IOException

Implements abstract org.glassfish.jaxb.runtime.v2.runtime.output.Pcdata.writeTo.

Doc from org.glassfish.jaxb.runtime.v2.runtime.output.Pcdata.writeTo.

Writes itself to UTF8XmlOutput.

This is the most performance critical path for the marshaller, so it warrants its own method.

Annotations
@Override
writeToback to summary
public void writeTo(XMLStreamWriter output) throws IOException, XMLStreamException
Annotations
@SuppressWarnings:deprecation