C
- one of the classes (or the <?> wildcard for any of the classes) registered with the JAXB Contextpublic class JAXBHandle<C> extends BaseHandle<InputStream,OutputStreamSender> implements OutputStreamSender, BufferableHandle, ContentHandle<C>, XMLReadHandle, XMLWriteHandle
UNKNOWN_LENGTH
Constructor and Description |
---|
JAXBHandle(JAXBContext context)
Initializes the JAXB handle with the JAXB context for the classes
of the marshalled or unmarshalled structure.
|
Modifier and Type | Method and Description |
---|---|
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(Class<T> as)
Returns the root object of the JAXB structure for the content
cast to a more specific class.
|
Marshaller |
getMarshaller()
Returns the marshaller that converts a tree data structure
from Java objects to XML, reusing any existing marshaller.
|
Marshaller |
getMarshaller(boolean reuse)
Returns the marshaller that converts a tree data structure
from Java objects to XML.
|
Unmarshaller |
getUnmarshaller()
Returns the unmarshaller that converts a tree data structure
from XML to Java objects, reusing any existing unmarshaller.
|
Unmarshaller |
getUnmarshaller(boolean reuse)
Returns the unmarshaller that converts a tree data structure
from XML to Java objects.
|
static ContentHandleFactory |
newFactory(Class<?>... pojoClasses)
Creates a factory to create a JAXBHandle instance for POJO instances
of the specified classes.
|
static ContentHandleFactory |
newFactory(JAXBContext context,
Class<?>... pojoClasses)
Creates a factory to create a JAXBHandle instance for POJO instances
of the specified classes.
|
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.
|
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(String mimetype)
Specifies the mime type of the content and returns the handle
as a fluent convenience.
|
void |
write(OutputStream out)
Implements a callback to write content to the provided output stream
for sending to the database server.
|
getByteLength, getFormat, getMimetype, setByteLength, setMimetype
public JAXBHandle(JAXBContext context)
context
- the JAXB contextpublic static ContentHandleFactory newFactory(Class<?>... pojoClasses) throws JAXBException
pojoClasses
- the POJO classes for which this factory provides a handleJAXBException
public static ContentHandleFactory newFactory(JAXBContext context, Class<?>... pojoClasses) throws JAXBException
context
- the JAXB context for marshaling the POJO classespojoClasses
- the POJO classes for which this factory provides a handleJAXBException
public C get()
get
in interface ContentHandle<C>
public <T> T get(Class<T> as)
as
- 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 void setFormat(Format format)
setFormat
in interface ContentDescriptor
setFormat
in class BaseHandle<InputStream,OutputStreamSender>
format
- the format of the contentpublic JAXBHandle<C> withMimetype(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 String toString()
public Unmarshaller getUnmarshaller() throws JAXBException
JAXBException
public Unmarshaller getUnmarshaller(boolean reuse) throws JAXBException
reuse
- whether to reuse an existing unmarshallerJAXBException
public Marshaller getMarshaller() throws JAXBException
JAXBException
public Marshaller getMarshaller(boolean reuse) throws JAXBException
reuse
- whether to reuse an existing marshallerJAXBException
public void write(OutputStream out) throws IOException
OutputStreamSender
write
in interface OutputStreamSender
out
- the output stream receiving the contentIOException
Copyright © 2013-2015 MarkLogic Corporation.