java.lang.Object
org.jvnet.staxex.Base64Data
- All Implemented Interfaces:
CharSequence
,Cloneable
Binary data represented as base64-encoded string
in XML.
Used in conjunction with XMLStreamReaderEx
and XMLStreamWriterEx
.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate final class
private final class
private static final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private byte[]
private boolean
True ifdata
can be cloned by reference if Base64Data instance is cloned.private jakarta.activation.DataHandler
private int
Length of the valid data indata
.private String
private static final Logger
private String
Optional MIME type ofdata
. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionchar
charAt
(int index) Encode this binary data in the base64 encoding and returns the character at the specified position.clone()
byte[]
get()
Gets the raw data.jakarta.activation.DataHandler
Gets the raw data.int
Gets the length of the binary data counted in bytes.byte[]
getExact()
Gets the byte[] of the exact length.Gets the data as anInputStream
.(package private) static String
getProperty
(String propName) boolean
hasData()
Returns false if this object only hasDataHandler
and thereforeget()
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
Fills in the data object by a portion of the byte[].void
Fills in the data object by a portion of the byte[].void
Fills in the data object by the byte[] of the exact length.void
set
(jakarta.activation.DataHandler data) Fills in the data object by aDataHandler
.void
setHrefCid
(String cid) 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.toString()
Returns the base64 encoded string of this data.void
writeTo
(char[] buf, int start) void
writeTo
(XMLStreamWriter output) Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.CharSequence
chars, codePoints
-
Field Details
-
dataHandler
private jakarta.activation.DataHandler dataHandler -
data
private byte[] data -
hrefCid
-
dataLen
private int dataLenLength of the valid data indata
. -
dataCloneByRef
private boolean dataCloneByRefTrue ifdata
can be cloned by reference if Base64Data instance is cloned. -
mimeType
Optional MIME type ofdata
. Unused whendataHandler
is set. UseDataHandler.getContentType()
in that case. -
logger
-
CHUNK_SIZE
private static final int CHUNK_SIZE
-
-
Constructor Details
-
Base64Data
public Base64Data()Default constructor -
Base64Data
Clone constructor- Parameters:
that
- needs to be cloned
-
-
Method Details
-
set
Fills in the data object by a portion of the byte[].- Parameters:
data
- actual datalen
- data[0] to data[len-1] are treated as the data.mimeType
- MIME typecloneByRef
- true if data[] can be cloned by reference
-
set
Fills in the data object by a portion of the byte[].- Parameters:
data
- actual data byteslen
- data[0] to data[len-1] are treated as the data.mimeType
- MIME type
-
set
Fills in the data object by the byte[] of the exact length.- Parameters:
data
- this buffer may be owned directly by the unmarshaleld JAXB object.mimeType
- MIME type
-
set
public void set(jakarta.activation.DataHandler data) Fills in the data object by aDataHandler
.- Parameters:
data
- DataHandler for the data
-
getDataHandler
public jakarta.activation.DataHandler getDataHandler()Gets the raw data. If the returned DataHandler isStreamingDataHandler
, callees may need to downcast to take advantage of its capabilities.- Returns:
- DataHandler for the data
- See Also:
-
getExact
public byte[] getExact()Gets the byte[] of the exact length.- Returns:
- byte[] for data
-
getInputStream
Gets the data as anInputStream
.- Returns:
- data as InputStream
- Throws:
IOException
- if i/o error occurs
-
hasData
public boolean hasData()Returns false if this object only hasDataHandler
and thereforeget()
operation is likely going to be expensive.- Returns:
- false if it has only DataHandler
-
get
public byte[] get()Gets the raw data. The size of the byte array maybe larger than the actual length.- Returns:
- data as byte[], the array may be larger
-
getDataLen
public int getDataLen()Gets the length of the binary data counted in bytes. Note that if this object encapsulatesDataHandler
, this method would have to read the whole thing intobyte[]
just to count the length, becauseDataHandler
doesn't easily expose the length.- Returns:
- no of bytes
-
getMimeType
-
length
public int length()Gets the number of characters needed to represent this binary data in the base64 encoding.- Specified by:
length
in interfaceCharSequence
-
charAt
public char charAt(int index) Encode this binary data in the base64 encoding and returns the character at the specified position.- Specified by:
charAt
in interfaceCharSequence
-
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.- Specified by:
subSequence
in interfaceCharSequence
-
toString
Returns the base64 encoded string of this data.- Specified by:
toString
in interfaceCharSequence
- Overrides:
toString
in classObject
-
writeTo
public void writeTo(char[] buf, int start) -
writeTo
- Throws:
IOException
XMLStreamException
-
clone
-
getProperty
-
getHrefCid
-
setHrefCid
-