C
- one of the classes (or the <?> wildcard
for any of the classes) registered with the JAXB Contextpublic class JAXBHandle<C> extends BaseHandle<java.io.InputStream,OutputStreamSender> implements ResendableContentHandle<C,java.io.InputStream>, OutputStreamSender, XMLReadHandle, XMLWriteHandle
UNKNOWN_LENGTH
Constructor and Description |
---|
JAXBHandle(jakarta.xml.bind.JAXBContext context)
Initializes the JAXB handle with the JAXB
context for the classes of the marshalled or unmarshalled
structure.
|
JAXBHandle(jakarta.xml.bind.JAXBContext context,
java.lang.Class<C> contentClass)
Initializes the JAXB handle with the JAXB
context for the classes of the marshalled or unmarshalled
structure.
|
Modifier and Type | Method and Description |
---|---|
C |
bytesToContent(byte[] buffer)
Converts a byte serialization to the content
representation.
|
byte[] |
contentToBytes(C content)
Converts the content representation to
bytes.
|
void |
fromBuffer(byte[] buffer)
fromBuffer() unmarshals a JAXB POJO from a byte
array buffer.
|
C |
get()
Returns the root object of the JAXB structure
for the content.
|
<T> T |
get(java.lang.Class<T> as)
Returns the root object of the JAXB structure
for the content cast to a more specific class.
|
java.lang.Class<C> |
getContentClass()
Returns the class of the handled content, which
may be a base class of the actual class of a content object.
|
jakarta.xml.bind.Marshaller |
getMarshaller()
Returns the marshaller that converts a tree data
structure from Java objects to XML, reusing any existing
marshaller.
|
jakarta.xml.bind.Marshaller |
getMarshaller(boolean reuse)
Returns the marshaller that converts a tree data
structure from Java objects to XML.
|
jakarta.xml.bind.Unmarshaller |
getUnmarshaller()
Returns the unmarshaller that converts a tree
data structure from XML to Java objects, reusing any existing
unmarshaller.
|
jakarta.xml.bind.Unmarshaller |
getUnmarshaller(boolean reuse)
Returns the unmarshaller that converts a tree
data structure from XML to Java objects.
|
static ContentHandleFactory |
newFactory(java.lang.Class<?>... pojoClasses)
Creates a factory to create a JAXBHandle
instance for POJO instances of the specified classes.
|
static ContentHandleFactory |
newFactory(jakarta.xml.bind.JAXBContext context,
java.lang.Class<?>... pojoClasses)
Creates a factory to create a JAXBHandle
instance for POJO instances of the specified classes.
|
JAXBHandle<C> |
newHandle()
Constructs a new handle for the same content
representation, initializing the new handle with the same format
and mime type.
|
JAXBHandle<C>[] |
newHandleArray(int length)
Constructs an uninitialized array with the
specified length with items of the same content
representation.
|
protected
java.lang.Class<java.io.InputStream> |
receiveAs() |
protected void |
receiveContent(java.io.InputStream serialization) |
protected OutputStreamSender |
sendContent() |
void |
set(C content)
Assigns the root object of the JAXB structure
for the content.
|
void |
setFormat(Format format)
Restricts the format to XML.
|
byte[] |
toBuffer()
Copies the content of the handle to a byte array
buffer encoded in UTF-8.
|
C |
toContent(java.io.InputStream serialization)
Converts the serialization to the content
representation.
|
java.lang.String |
toString()
Returns the JAXB structure as an XML
string.
|
JAXBHandle<C> |
with(C content)
Assigns the root object of the JAXB structure
for the content and returns the handle as a fluent
convenience.
|
JAXBHandle<C> |
withMimetype(java.lang.String mimetype)
Specifies the mime type of the content and
returns the handle as a fluent convenience.
|
void |
write(java.io.OutputStream out)
Implements a callback to write content to the
provided output stream for sending to the database server.
|
getByteLength,
getFormat,
getMimetype,
getServerTimestamp,
setByteLength,
setMimetype,
setServerTimestamp
getPointInTimeQueryTimestamp, isResendable,
setPointInTimeQueryTimestamp, setResendable,
setResponseServerTimestamp
clone, equals, finalize, getClass, hashCode, notify,
notifyAll, wait, wait, wait
newHandle,
resendableHandleFor
resendableHandleFor
newArray
public JAXBHandle(jakarta.xml.bind.JAXBContext context)
context
- the JAXB contextpublic JAXBHandle(jakarta.xml.bind.JAXBContext context, java.lang.Class<C> contentClass)
context
- the JAXB contextcontentClass
- the class of the contentpublic static ContentHandleFactory newFactory(java.lang.Class<?>... pojoClasses) throws jakarta.xml.bind.JAXBException
pojoClasses
- the POJO classes for which this
factory provides a handlejakarta.xml.bind.JAXBException
- if a JAXB error
occurs while initializing the new factorypublic static ContentHandleFactory newFactory(jakarta.xml.bind.JAXBContext context, java.lang.Class<?>... pojoClasses)
context
- the JAXB context for marshaling the POJO
classespojoClasses
- the POJO classes for which this
factory provides a handlepublic C get()
get
in interface ContentHandle<C>
public <T> T get(java.lang.Class<T> as)
T
- the type to returnas
- the class of the objectpublic void set(C content)
set
in interface ContentHandle<C>
content
- the root JAXB objectpublic JAXBHandle<C> with(C content)
content
- the root JAXB objectpublic java.lang.Class<C> getContentClass()
ContentHandle
getContentClass
in interface ContentHandle<C>
public JAXBHandle<C> newHandle()
ContentHandle
newHandle
in interface BufferableContentHandle<C,java.io.InputStream>
newHandle
in interface ContentHandle<C>
newHandle
in interface ResendableContentHandle<C,java.io.InputStream>
public JAXBHandle<C>[] newHandleArray(int length)
BufferableContentHandle
newHandleArray
in interface BufferableContentHandle<C,java.io.InputStream>
newHandleArray
in interface ResendableContentHandle<C,java.io.InputStream>
length
- the number of positions in the arraypublic void setFormat(Format format)
setFormat
in interface ContentDescriptor
setFormat
in class BaseHandle<java.io.InputStream,OutputStreamSender>
format
- the format of the contentpublic JAXBHandle<C> withMimetype(java.lang.String mimetype)
mimetype
- the mime type of the contentpublic void fromBuffer(byte[] buffer)
fromBuffer
in interface BufferableHandle
buffer
- the byte arraypublic byte[] toBuffer()
BufferableHandle
toBuffer
in interface BufferableHandle
public C bytesToContent(byte[] buffer)
BufferableContentHandle
bytesToContent
in interface BufferableContentHandle<C,java.io.InputStream>
buffer
- the byte serializationpublic byte[] contentToBytes(C content)
BufferableContentHandle
contentToBytes
in interface BufferableContentHandle<C,java.io.InputStream>
content
- the contentpublic C toContent(java.io.InputStream serialization)
BufferableContentHandle
toContent
in interface BufferableContentHandle<C,java.io.InputStream>
serialization
- a serialization of the
contentpublic java.lang.String toString()
toString
in
class java.lang.Object
public jakarta.xml.bind.Unmarshaller getUnmarshaller() throws jakarta.xml.bind.JAXBException
jakarta.xml.bind.JAXBException
- if unmarshaller
initialization failspublic jakarta.xml.bind.Unmarshaller getUnmarshaller(boolean reuse) throws jakarta.xml.bind.JAXBException
reuse
- whether to reuse an existing
unmarshallerjakarta.xml.bind.JAXBException
- if unmarshaller
initialization failspublic jakarta.xml.bind.Marshaller getMarshaller() throws jakarta.xml.bind.JAXBException
jakarta.xml.bind.JAXBException
- if marshaller
initialization failspublic jakarta.xml.bind.Marshaller getMarshaller(boolean reuse) throws jakarta.xml.bind.JAXBException
reuse
- whether to reuse an existing
marshallerjakarta.xml.bind.JAXBException
- if marshaller
initialization failsprotected java.lang.Class<java.io.InputStream> receiveAs()
receiveAs
in
class com.marklogic.client.impl.HandleImplementation<java.io.InputStream,OutputStreamSender>
protected void receiveContent(java.io.InputStream serialization)
receiveContent
in
class com.marklogic.client.impl.HandleImplementation<java.io.InputStream,OutputStreamSender>
protected OutputStreamSender sendContent()
sendContent
in
class com.marklogic.client.impl.HandleImplementation<java.io.InputStream,OutputStreamSender>
public void write(java.io.OutputStream out) throws java.io.IOException
OutputStreamSender
write
in interface OutputStreamSender
out
- the output stream receiving the contentjava.io.IOException
- if io problems ariseCopyright © 2024 MarkLogic Corporation. All Rights Reserved.