org.jboss.resteasy.core.interception

## Class AbstractWriterInterceptorContext

- java.lang.Object
- - org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext

- All Implemented Interfaces:
    InterceptorContext, WriterInterceptorContext
  Direct Known Subclasses:
    ClientWriterInterceptorContext, ServerWriterInterceptorContext

      public abstract class AbstractWriterInterceptorContext
      extends Object
      implements WriterInterceptorContext

  Version:
    $Revision: 1 $
  Author:
    Bill Burke

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Annotation[]` | `annotations`
    `protected Object` | `entity`
    `protected Type` | `genericType`
    `protected MultivaluedMap<String,Object>` | `headers`
    `protected int` | `index`
    `protected WriterInterceptor[]` | `interceptors`
    `protected MediaType` | `mediaType`
    `protected OutputStream` | `outputStream`
    `protected ResteasyProviderFactory` | `providerFactory`
    `protected Class` | `type`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractWriterInterceptorContext(WriterInterceptor[] interceptors, Annotation[] annotations, Object entity, Type genericType, MediaType mediaType, Class type, OutputStream outputStream, ResteasyProviderFactory providerFactory, MultivaluedMap<String,Object> headers)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Annotation[]` | `getAnnotations()` Get an array of the annotations formally declared on the artifact that initiated the intercepted entity provider invocation.
    `Object` | `getEntity()` Get object to be written as HTTP entity.
    `Type` | `getGenericType()` Get the type of the object to be produced or written.
    `MultivaluedMap<String,Object>` | `getHeaders()` Get mutable map of HTTP headers.
    `MediaType` | `getMediaType()` Get media type of HTTP entity.
    `OutputStream` | `getOutputStream()` Get the output stream for the object to be written.
    `Class` | `getType()` Get Java type supported by corresponding message body provider.
    `protected MessageBodyWriter` | `getWriter()`
    `void` | `proceed()` Proceed to the next interceptor in the chain.
    `protected abstract MessageBodyWriter` | `resolveWriter()`
    `void` | `setAnnotations(Annotation[] annotations)` Update annotations on the formal declaration of the artifact that initiated the intercepted entity provider invocation.
    `void` | `setEntity(Object entity)` Update object to be written as HTTP entity.
    `void` | `setGenericType(Type genericType)` Update type of the object to be produced or written.
    `void` | `setMediaType(MediaType mediaType)` Update media type of HTTP entity.
    `void` | `setOutputStream(OutputStream outputStream)` Set a new output stream for the object to be written.
    `void` | `setType(Class type)` Update Java type before calling message body provider.
    `protected void` | `writeTo(MessageBodyWriter writer)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface javax.ws.rs.ext.InterceptorContext

      `getProperty, getPropertyNames, removeProperty, setProperty`

- - ### Field Detail

    - #### interceptors

          protected WriterInterceptor[] interceptors

    - #### entity

          protected Object entity

    - #### type

          protected Class type

    - #### genericType

          protected Type genericType

    - #### annotations

          protected Annotation[] annotations

    - #### mediaType

          protected MediaType mediaType

    - #### headers

          protected MultivaluedMap<String,Object> headers

    - #### outputStream

          protected OutputStream outputStream

    - #### index

          protected int index

    - #### providerFactory

          protected ResteasyProviderFactory providerFactory

  - ### Constructor Detail

    - #### AbstractWriterInterceptorContext

          public AbstractWriterInterceptorContext(WriterInterceptor[] interceptors,
                                          Annotation[] annotations,
                                          Object entity,
                                          Type genericType,
                                          MediaType mediaType,
                                          Class type,
                                          OutputStream outputStream,
                                          ResteasyProviderFactory providerFactory,
                                          MultivaluedMap<String,Object> headers)

  - ### Method Detail

    - #### getEntity

          public Object getEntity()

      Description copied from interface: `WriterInterceptorContext`
      Get object to be written as HTTP entity.
      Specified by:
        `getEntity` in interface `WriterInterceptorContext`
      Returns:
        object to be written as HTTP entity.

    - #### setEntity

          public void setEntity(Object entity)

      Description copied from interface: `WriterInterceptorContext`
      Update object to be written as HTTP entity.
      Specified by:
        `setEntity` in interface `WriterInterceptorContext`
      Parameters:
        `entity` - new object to be written.

    - #### getType

          public Class getType()

      Description copied from interface: `InterceptorContext`
      Get Java type supported by corresponding message body provider.
      Specified by:
        `getType` in interface `InterceptorContext`
      Returns:
        java type supported by provider

    - #### setType

          public void setType(Class type)

      Description copied from interface: `InterceptorContext`
      Update Java type before calling message body provider.
      Specified by:
        `setType` in interface `InterceptorContext`
      Parameters:
        `type` - java type for provider

    - #### getGenericType

          public Type getGenericType()

      Description copied from interface: `InterceptorContext`
      Get the type of the object to be produced or written.
      Specified by:
        `getGenericType` in interface `InterceptorContext`
      Returns:
        type of object produced or written

    - #### setGenericType

          public void setGenericType(Type genericType)

      Description copied from interface: `InterceptorContext`
      Update type of the object to be produced or written.
      Specified by:
        `setGenericType` in interface `InterceptorContext`
      Parameters:
        `genericType` - new type for object

    - #### getAnnotations

          public Annotation[] getAnnotations()

      Description copied from interface: `InterceptorContext`
      Get an array of the annotations formally declared on the artifact that initiated the intercepted entity provider invocation. E.g. if the message body is to be converted into a method parameter, this will be the annotations on that parameter returned by `Method.getParameterAnnotations()`; if the server-side response entity instance is to be converted into an output stream, this will be the annotations on the matched resource method returned by `Method.getAnnotations()`. This method may return an empty array in case the interceptor is not invoked in a context of any particular resource method (e.g. as part of the client API), but will never return `null`.
      Specified by:
        `getAnnotations` in interface `InterceptorContext`
      Returns:
        annotations declared on the artifact that initiated the intercepted entity provider invocation.

    - #### setAnnotations

          public void setAnnotations(Annotation[] annotations)

      Description copied from interface: `InterceptorContext`
      Update annotations on the formal declaration of the artifact that initiated the intercepted entity provider invocation. Calling this method has no effect in the client API.
      Specified by:
        `setAnnotations` in interface `InterceptorContext`
      Parameters:
        `annotations` - updated annotations declarataion of the artifact that initiated the intercepted entity provider invocation. Must not be `null`.

    - #### getMediaType

          public MediaType getMediaType()

      Description copied from interface: `InterceptorContext`
      Get media type of HTTP entity.
      Specified by:
        `getMediaType` in interface `InterceptorContext`
      Returns:
        media type of HTTP entity

    - #### setMediaType

          public void setMediaType(MediaType mediaType)

      Description copied from interface: `InterceptorContext`
      Update media type of HTTP entity.
      Specified by:
        `setMediaType` in interface `InterceptorContext`
      Parameters:
        `mediaType` - new type for HTTP entity

    - #### getHeaders

          public MultivaluedMap<String,Object> getHeaders()

      Description copied from interface: `WriterInterceptorContext`
      Get mutable map of HTTP headers.
      Specified by:
        `getHeaders` in interface `WriterInterceptorContext`
      Returns:
        map of HTTP headers.

    - #### getOutputStream

          public OutputStream getOutputStream()

      Description copied from interface: `WriterInterceptorContext`
      Get the output stream for the object to be written. The JAX-RS runtime is responsible for closing the output stream.
      Specified by:
        `getOutputStream` in interface `WriterInterceptorContext`
      Returns:
        output stream for the object to be written.

    - #### setOutputStream

          public void setOutputStream(OutputStream outputStream)

      Description copied from interface: `WriterInterceptorContext`
      Set a new output stream for the object to be written. For example, by wrapping it with another output stream. The JAX-RS runtime is responsible for closing the output stream that is set.
      Specified by:
        `setOutputStream` in interface `WriterInterceptorContext`
      Parameters:
        `outputStream` - new output stream for the object to be written.

    - #### proceed

          public void proceed()
                       throws IOException,
                              WebApplicationException

      Description copied from interface: `WriterInterceptorContext`
      Proceed to the next interceptor in the chain. Interceptors MUST explicitly call this method to continue the execution chain; the call to this method in the last interceptor of the chain will invoke the wrapped `MessageBodyWriter.writeTo(T, java.lang.Class<?>, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap<java.lang.String, java.lang.Object>, java.io.OutputStream)` method.
      Specified by:
        `proceed` in interface `WriterInterceptorContext`
      Throws:
        `IOException` - if an IO error arises or is thrown by the wrapped `MessageBodyWriter.writeTo` method.
        `WebApplicationException` - thrown by the wrapped `MessageBodyWriter.writeTo` method.

    - #### writeTo

          protected void writeTo(MessageBodyWriter writer)
                          throws IOException

      Throws:
        `IOException`

    - #### getWriter

          protected MessageBodyWriter getWriter()

    - #### resolveWriter

          protected abstract MessageBodyWriter resolveWriter()

Copyright © 2014. All Rights Reserved.