public class Base64Data
extends java.lang.Object
implements java.lang.CharSequence, java.lang.Cloneable
Used in conjunction with XMLStreamReaderEx
and XMLStreamWriterEx
.
Modifier and Type | Class and Description |
---|---|
private class |
Base64Data.Base64DataSource |
private class |
Base64Data.Base64StreamingDataHandler |
private static class |
Base64Data.FilterDataHandler |
Modifier and Type | Field and Description |
---|---|
private static int |
CHUNK_SIZE |
private byte[] |
data |
private boolean |
dataCloneByRef
True if
data can be cloned by reference
if Base64Data instance is cloned. |
private javax.activation.DataHandler |
dataHandler |
private int |
dataLen
Length of the valid data in
data . |
private java.lang.String |
hrefCid |
private static java.util.logging.Logger |
logger |
private java.lang.String |
mimeType
Optional MIME type of
data . |
Constructor and Description |
---|
Base64Data()
Default constructor
|
Base64Data(Base64Data that)
Clone constructor
|
Modifier and Type | Method and Description |
---|---|
char |
charAt(int index)
Encode this binary data in the base64 encoding
and returns the character at the specified position.
|
Base64Data |
clone() |
byte[] |
get()
Gets the raw data.
|
javax.activation.DataHandler |
getDataHandler()
Gets the raw data.
|
int |
getDataLen()
Gets the length of the binary data counted in bytes.
|
byte[] |
getExact()
Gets the byte[] of the exact length.
|
java.lang.String |
getHrefCid() |
java.io.InputStream |
getInputStream()
Gets the data as an
InputStream . |
java.lang.String |
getMimeType() |
(package private) static java.lang.String |
getProperty(java.lang.String propName) |
boolean |
hasData()
Returns false if this object only has
DataHandler and therefore
get() operation is likely going to be expensive. |
int |
length()
Gets the number of characters needed to represent
this binary data in the base64 encoding.
|
void |
set(byte[] data,
int len,
java.lang.String mimeType)
Fills in the data object by a portion of the byte[].
|
void |
set(byte[] data,
int len,
java.lang.String mimeType,
boolean cloneByRef)
Fills in the data object by a portion of the byte[].
|
void |
set(byte[] data,
java.lang.String mimeType)
Fills in the data object by the byte[] of the exact length.
|
void |
set(javax.activation.DataHandler data)
Fills in the data object by a
DataHandler . |
void |
setHrefCid(java.lang.String cid) |
java.lang.CharSequence |
subSequence(int start,
int end)
Internally this is only used to split a text to a list,
which doesn't happen that much for base64.
|
java.lang.String |
toString()
Returns the base64 encoded string of this data.
|
void |
writeTo(char[] buf,
int start) |
void |
writeTo(javax.xml.stream.XMLStreamWriter output) |
private javax.activation.DataHandler dataHandler
private byte[] data
private java.lang.String hrefCid
private int dataLen
data
.private boolean dataCloneByRef
data
can be cloned by reference
if Base64Data instance is cloned.private java.lang.String mimeType
data
.
Unused when dataHandler
is set.
Use DataHandler.getContentType()
in that case.private static final java.util.logging.Logger logger
private static final int CHUNK_SIZE
public Base64Data()
public Base64Data(Base64Data that)
that
- needs to be clonedpublic void set(byte[] data, int len, java.lang.String mimeType, boolean cloneByRef)
data
- actual datalen
- data[0] to data[len-1] are treated as the data.mimeType
- MIME typecloneByRef
- true if data[] can be cloned by referencepublic void set(byte[] data, int len, java.lang.String mimeType)
data
- actual data byteslen
- data[0] to data[len-1] are treated as the data.mimeType
- MIME typepublic void set(byte[] data, java.lang.String mimeType)
data
- this buffer may be owned directly by the unmarshaleld JAXB object.mimeType
- MIME typepublic void set(javax.activation.DataHandler data)
DataHandler
.data
- DataHandler for the datapublic javax.activation.DataHandler getDataHandler()
StreamingDataHandler
,
callees may need to downcast to take advantage of its capabilities.StreamingDataHandler
public byte[] getExact()
public java.io.InputStream getInputStream() throws java.io.IOException
InputStream
.java.io.IOException
- if i/o error occurspublic boolean hasData()
DataHandler
and therefore
get()
operation is likely going to be expensive.public byte[] get()
public int getDataLen()
DataHandler
,
this method would have to read the whole thing into byte[]
just to count the length, because DataHandler
doesn't easily expose the length.public java.lang.String getMimeType()
public int length()
length
in interface java.lang.CharSequence
public char charAt(int index)
charAt
in interface java.lang.CharSequence
public java.lang.CharSequence subSequence(int start, int end)
subSequence
in interface java.lang.CharSequence
public java.lang.String toString()
toString
in interface java.lang.CharSequence
toString
in class java.lang.Object
public void writeTo(char[] buf, int start)
public void writeTo(javax.xml.stream.XMLStreamWriter output) throws java.io.IOException, javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
public Base64Data clone()
clone
in class java.lang.Object
static java.lang.String getProperty(java.lang.String propName)
public java.lang.String getHrefCid()
public void setHrefCid(java.lang.String cid)