Class DocumentProvider
java.lang.Object
org.jboss.resteasy.plugins.providers.AbstractEntityProvider<Document>
org.jboss.resteasy.plugins.providers.DocumentProvider
- All Implemented Interfaces:
MessageBodyReader<Document>,MessageBodyWriter<Document>,AsyncBufferedMessageBodyWriter<Document>,AsyncMessageBodyWriter<Document>
@Provider
@Produces({"text/xml","text/*+xml","application/xml","application/*+xml"})
@Consumes({"text/xml","text/*+xml","application/xml","application/*+xml"})
public class DocumentProvider
extends AbstractEntityProvider<Document>
implements AsyncBufferedMessageBodyWriter<Document>
Provider that reads and writes org.w3c.dom.Document.
- Version:
- $Revision: $
- Author:
- Solomon Duskis
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanisReadable(Class<?> clazz, Type type, Annotation[] annotation, MediaType mediaType) Ascertain if the MessageBodyReader can produce an instance of a particular type.booleanisWriteable(Class<?> clazz, Type type, Annotation[] annotation, MediaType mediaType) Ascertain if the MessageBodyWriter supports a particular type.readFrom(Class<Document> clazz, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> headers, InputStream input) Read a type from theInputStream.voidwriteTo(Document document, Class<?> clazz, Type type, Annotation[] annotation, MediaType mediaType, MultivaluedMap<String, Object> headers, OutputStream output) Write a type to an HTTP message.Methods inherited from class org.jboss.resteasy.plugins.providers.AbstractEntityProvider
getSizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jboss.resteasy.core.messagebody.AsyncBufferedMessageBodyWriter
asyncWriteToMethods inherited from interface jakarta.ws.rs.ext.MessageBodyWriter
getSize
-
Constructor Details
-
DocumentProvider
public DocumentProvider() -
DocumentProvider
-
-
Method Details
-
isReadable
Description copied from interface:MessageBodyReaderAscertain if the MessageBodyReader can produce an instance of a particular type. Thetypeparameter gives the class of the instance that should be produced, thegenericTypeparameter gives thejava.lang.reflect.Typeof the instance that should be produced. E.g. if the instance to be produced isList<String>, thetypeparameter will bejava.util.Listand thegenericTypeparameter will bejava.lang.reflect.ParameterizedType.- Specified by:
isReadablein interfaceMessageBodyReader<Document>- Parameters:
clazz- the class of instance to be produced.type- the type of instance to be produced. E.g. if the message body is to be converted into a method parameter, this will be the formal type of the method parameter as returned byMethod.getGenericParameterTypes.annotation- an array of the annotations on the declaration of the artifact that will be initialized with the produced instance. E.g. if the message body is to be converted into a method parameter, this will be the annotations on that parameter returned byMethod.getParameterAnnotations.mediaType- the media type of the HTTP entity, if one is not specified in the request thenapplication/octet-streamis used.- Returns:
trueif the type is supported, otherwisefalse.
-
readFrom
public Document readFrom(Class<Document> clazz, Type type, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> headers, InputStream input) throws IOException, WebApplicationExceptionDescription copied from interface:MessageBodyReaderRead a type from theInputStream.In case the entity input stream is empty, the reader is expected to either return a Java representation of a zero-length entity or throw a
NoContentExceptionin case no zero-length entity representation is defined for the supported Java type. ANoContentException, if thrown by a message body reader while reading a server request entity, is automatically translated by JAX-RS server runtime into aBadRequestExceptionwrapping the originalNoContentExceptionand rethrown for a standard processing by the registeredexception mappers.- Specified by:
readFromin interfaceMessageBodyReader<Document>- Parameters:
clazz- the type that is to be read from the entity stream.type- the type of instance to be produced. E.g. if the message body is to be converted into a method parameter, this will be the formal type of the method parameter as returned byMethod.getGenericParameterTypes.annotations- an array of the annotations on the declaration of the artifact that will be initialized with the produced instance. E.g. if the message body is to be converted into a method parameter, this will be the annotations on that parameter returned byMethod.getParameterAnnotations.mediaType- the media type of the HTTP entity.headers- the read-only HTTP headers associated with HTTP entity.input- theInputStreamof 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.- Returns:
- the type that was read from the stream. In case the entity input stream is empty, the reader is expected to
either return an instance representing a zero-length entity or throw a
NoContentExceptionin case no zero-length entity representation is defined for the supported Java type. - Throws:
IOException- if an IO error arises. In case the entity input stream is empty and the reader is not able to produce a Java representation for a zero-length entity,NoContentExceptionis expected to be thrown.WebApplicationException- if a specific HTTP error response needs to be produced. Only effective if thrown prior to the response being committed.
-
isWriteable
Description copied from interface:MessageBodyWriterAscertain if the MessageBodyWriter supports a particular type.- Specified by:
isWriteablein interfaceMessageBodyWriter<Document>- Parameters:
clazz- the class of instance that is to be written.type- the type of instance to be written, obtained either by reflection of a resource method return type or via inspection of the returned instance.GenericEntityprovides a way to specify this information at runtime.annotation- an array of the annotations attached to the message entity instance.mediaType- the media type of the HTTP entity.- Returns:
trueif the type is supported, otherwisefalse.
-
writeTo
public void writeTo(Document document, Class<?> clazz, Type type, Annotation[] annotation, MediaType mediaType, MultivaluedMap<String, Object> headers, OutputStream output) throws IOException, WebApplicationExceptionDescription copied from interface:MessageBodyWriterWrite a type to an HTTP message. The message header map is mutable but any changes must be made before writing to the output stream since the headers will be flushed prior to writing the message body.- Specified by:
writeToin interfaceMessageBodyWriter<Document>- Parameters:
document- the instance to write.clazz- the class of instance that is to be written.type- the type of instance to be written.GenericEntityprovides a way to specify this information at runtime.annotation- an array of the annotations attached to the message entity instance.mediaType- the media type of the HTTP entity.headers- a mutable map of the HTTP message headers.output- theOutputStreamfor the HTTP entity. The implementation must not close the output stream.- Throws:
IOException- if an IO error arises.WebApplicationException- if a specific HTTP error response needs to be produced. Only effective if thrown prior to the message being committed.
-