public abstract class AbstractJaxbElementProvider extends AbstractJaxbProvider<JAXBElement<?>>
JAXBElement
.
Implementing classes may extend this class to provide specific marshalling
and unmarshalling behaviour.
When unmarshalling a UnmarshalException
will result in a
WebApplicationException
being thrown with a status of 400
(Client error), and a JAXBException
will result in a
WebApplicationException
being thrown with a status of 500
(Internal Server error).
When marshalling a JAXBException
will result in a
WebApplicationException
being thrown with a status of 500
(Internal Server error).UTF8
Constructor and Description |
---|
AbstractJaxbElementProvider(Providers providers,
Configuration config)
Inheritance constructor.
|
AbstractJaxbElementProvider(Providers providers,
MediaType resolverMediaType,
Configuration config)
Inheritance constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
isReadable(Class<?> type,
Type genericType,
Annotation[] annotations,
MediaType mediaType) |
boolean |
isWriteable(Class<?> type,
Type genericType,
Annotation[] annotations,
MediaType mediaType) |
protected abstract JAXBElement<?> |
readFrom(Class<?> type,
MediaType mediaType,
Unmarshaller unmarshaller,
InputStream entityStream)
Read JAXB element from an entity stream.
|
JAXBElement<?> |
readFrom(Class<JAXBElement<?>> type,
Type genericType,
Annotation[] annotations,
MediaType mediaType,
MultivaluedMap<String,String> httpHeaders,
InputStream inputStream) |
void |
writeTo(JAXBElement<?> t,
Class<?> type,
Type genericType,
Annotation[] annotations,
MediaType mediaType,
MultivaluedMap<String,Object> httpHeaders,
OutputStream entityStream) |
protected abstract void |
writeTo(JAXBElement<?> element,
MediaType mediaType,
Charset charset,
Marshaller marshaller,
OutputStream entityStream)
Write JAXB element to an entity stream.
|
getMarshaller, getSAXSource, getStoredJaxbContext, getUnmarshaller, isFormattedOutput, isSupported, isXmlRootElementProcessing, setConfiguration, setHeader
getCharset, getSize, readFromAsString, writeTo, writeTo, writeToAsString
public AbstractJaxbElementProvider(Providers providers, Configuration config)
providers
- JAX-RS providers.public AbstractJaxbElementProvider(Providers providers, MediaType resolverMediaType, Configuration config)
providers
- JAX-RS providers.resolverMediaType
- JAXB component context resolver media type to be used.public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType)
public final JAXBElement<?> readFrom(Class<JAXBElement<?>> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,String> httpHeaders, InputStream inputStream) throws IOException
IOException
protected abstract JAXBElement<?> readFrom(Class<?> type, MediaType mediaType, Unmarshaller unmarshaller, InputStream entityStream) throws JAXBException
type
- the type that is to be read from the entity stream.mediaType
- the media type of the HTTP entity.unmarshaller
- JAXB unmarshaller to be used.entityStream
- the InputStream
of the HTTP entity. The
caller is responsible for ensuring that the input stream ends when the
entity has been consumed. The implementation should not close the input
stream.JAXBException
- in case entity unmarshalling fails.public final void writeTo(JAXBElement<?> t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,Object> httpHeaders, OutputStream entityStream) throws IOException
IOException
protected abstract void writeTo(JAXBElement<?> element, MediaType mediaType, Charset charset, Marshaller marshaller, OutputStream entityStream) throws JAXBException
element
- JAXB element to be written to an entity stream.mediaType
- the media type of the HTTP entity.charset
- character set to be used.marshaller
- JAXB unmarshaller to be used.entityStream
- the InputStream
of the HTTP entity. The
caller is responsible for ensuring that the input stream ends when the
entity has been consumed. The implementation should not close the input
stream.JAXBException
- in case entity marshalling fails.Copyright © 2007-2023, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.