- java.lang.Object
-
- org.glassfish.jaxb.runtime.v2.runtime.output.Pcdata
-
- org.glassfish.jaxb.runtime.v2.runtime.unmarshaller.Base64Data
-
- All Implemented Interfaces:
CharSequence
public final class Base64Data extends Pcdata
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)
-
-
Constructor Summary
Constructors Constructor Description Base64Data()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description charcharAt(int index)Encode this binary data in the base64 encoding and returns the character at the specified position.byte[]get()Gets the raw data.jakarta.activation.DataHandlergetDataHandler()Gets the raw data.intgetDataLen()byte[]getExact()Gets the byte[] of the exact length.InputStreamgetInputStream()Gets the data as anInputStream.StringgetMimeType()booleanhasData()Returns false if this object only hasDataHandlerand thereforeget()operation is likely going to be expensive.intlength()Gets the number of characters needed to represent this binary data in the base64 encoding.voidset(byte[] data, int len, String mimeType)Fills in the data object by a portion of the byte[].voidset(byte[] data, String mimeType)Fills in the data object by the byte[] of the exact length.voidset(jakarta.activation.DataHandler data)Fills in the data object by aDataHandler.CharSequencesubSequence(int start, int end)Internally this is only used to split a text to a list, which doesn't happen that much for base64.StringtoString()Returns the base64 encoded string of this data.voidwriteTo(char[] buf, int start)Writes itself to the character array.voidwriteTo(XMLStreamWriter output)voidwriteTo(UTF8XmlOutput output)Writes itself toUTF8XmlOutput.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.CharSequence
chars, codePoints
-
-
-
-
Method Detail
-
set
public void set(byte[] data, int len, @Nullable String mimeType)Fills in the data object by a portion of the byte[].- Parameters:
len- data[0] to data[len-1] are treated as the data.
-
set
public void set(byte[] data, @Nullable String mimeType)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.
-
set
public void set(jakarta.activation.DataHandler data)
Fills in the data object by aDataHandler.
-
getDataHandler
public jakarta.activation.DataHandler getDataHandler()
Gets the raw data.
-
getExact
public byte[] getExact()
Gets the byte[] of the exact length.
-
getInputStream
public InputStream getInputStream() throws IOException
Gets the data as anInputStream.- Throws:
IOException
-
hasData
public boolean hasData()
Returns false if this object only hasDataHandlerand thereforeget()operation is likely going to be expensive.
-
get
public byte[] get()
Gets the raw data. The size of the byte array maybe larger than the actual length.
-
getDataLen
public int getDataLen()
-
getMimeType
public String getMimeType()
-
length
public int length()
Gets the number of characters needed to represent this binary data in the base64 encoding.
-
charAt
public char charAt(int index)
Encode this binary data in the base64 encoding and returns the character at the specified position.
-
subSequence
public 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. So this method should be smaller than faster.
-
toString
public String toString()
Returns the base64 encoded string of this data.- Specified by:
toStringin interfaceCharSequence- Specified by:
toStringin classPcdata
-
writeTo
public void writeTo(char[] buf, int start)Description copied from class:PcdataWrites 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
CharSequence.length()method.
-
writeTo
public void writeTo(UTF8XmlOutput output) throws IOException
Description copied from class:PcdataWrites itself toUTF8XmlOutput.This is the most performance critical path for the marshaller, so it warrants its own method.
- Specified by:
writeToin classPcdata- Throws:
IOException
-
writeTo
public void writeTo(XMLStreamWriter output) throws IOException, XMLStreamException
- Throws:
IOExceptionXMLStreamException
-
-