Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.jersey.api
Class JResponse.AJResponseBuilder<E,B extends JResponse.AJResponseBuilder>

    java.lang.Object
      com.sun.jersey.api.JResponse.AJResponseBuilder<E,B>

Type Parameters:
  `E` - The entity type
  `B` - The builder type

Direct Known Subclasses:
  JResponse.JResponseBuilder

Enclosing class:
  JResponse<E>

    public abstract static class JResponse.AJResponseBuilder<E,B extends JResponse.AJResponseBuilder>

extends java.lang.Object

An abstract response builder that may be utilized to extend response building and the construction of `JResponse` instances.

Field Summary
`protected E` | `entity` The entity.
`protected OutBoundHeaders` | `headers` The response metadata.
`protected Response.StatusType` | `statusType` The status type.

Constructor Summary
`protected` | `JResponse.AJResponseBuilder()` Default constructor.
`protected` | `JResponse.AJResponseBuilder(JResponse.AJResponseBuilder<E,?> that)` Construct a shallow copy.

Method Summary
`B` | `cacheControl(CacheControl cacheControl)` Set the cache control.
`B` | `contentLocation(java.net.URI location)` Set the content location.
`B` | `cookie(NewCookie... cookies)` Add cookies.
`B` | `encoding(java.lang.String encoding)` Set the content encoding.
`B` | `entity(E entity)` Set the entity.
`B` | `expires(java.util.Date expires)` Set the expires date.
`protected E` | `getEntity()` Get the response entity.
`protected OutBoundHeaders` | `getMetadata()` Get the metadata associated with the response.
`protected int` | `getStatus()` Get the status code associated with the response.
`protected Response.StatusType` | `getStatusType()` Get the status type associated with the response.
`B` | `header(java.lang.String name, java.lang.Object value)` Add a header.
`B` | `header(java.lang.String name, java.lang.Object value, boolean single)` Add a header.
`B` | `headerSingle(java.lang.String name, java.lang.Object value)` Add a header or replace an existing header.
`B` | `language(java.util.Locale language)` Set the language.
`B` | `language(java.lang.String language)` Set the language.
`B` | `lastModified(java.util.Date lastModified)` Set the last modified date.
`B` | `location(java.net.URI location)` Set the location.
`protected void` | `reset()` Reset to the default state.
`B` | `status(int status)` Set the status.
`B` | `status(Response.Status status)` Set the status.
`B` | `status(Response.StatusType status)` Set the status.
`B` | `tag(EntityTag tag)` Set an entity tag.
`B` | `tag(java.lang.String tag)` Set a strong entity tag.
`B` | `type(MediaType type)` Set the response media type.
`B` | `type(java.lang.String type)` Set the response media type.
`B` | `variant(Variant variant)` Set representation metadata.
`B` | `variants(java.util.List<Variant> variants)` Add a Vary header that lists the available variants.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### statusType

    protected Response.StatusType statusType

  The status type.

### headers

    protected OutBoundHeaders headers

  The response metadata.

### entity

    protected E entity

  The entity.

Constructor Detail

### JResponse.AJResponseBuilder

    protected JResponse.AJResponseBuilder()

  Default constructor.

### JResponse.AJResponseBuilder

    protected JResponse.AJResponseBuilder(JResponse.AJResponseBuilder<E,?> that)

  Construct a shallow copy. The metadata map will be copied but not the key/value references.

  Parameters:
    `that` - the AJResponseBuilder to copy from.

Method Detail

### reset

    protected void reset()

  Reset to the default state.

### getStatusType

    protected Response.StatusType getStatusType()

  Get the status type associated with the response.

  Returns:
    the response status type.

### getStatus

    protected int getStatus()

  Get the status code associated with the response.

  Returns:
    the response status code.

### getMetadata

    protected OutBoundHeaders getMetadata()

  Get the metadata associated with the response.

  Returns:
    response metadata as a map

### getEntity

    protected E getEntity()

  Get the response entity.

  Returns:
    the response entity.

### status

    public B status(int status)

  Set the status.

  Parameters:
    `status` - the response status
  Returns:
    the updated instance
  Throws:
    `java.lang.IllegalArgumentException` - if status is less than 100 or greater than 599.

### status

    public B status(Response.StatusType status)

  Set the status.

  Parameters:
    `status` - the response status
  Returns:
    the updated instance.
  Throws:
    `java.lang.IllegalArgumentException` - if status is null

### status

    public B status(Response.Status status)

  Set the status.

  Parameters:
    `status` - the response status
  Returns:
    the updated instance.
  Throws:
    `java.lang.IllegalArgumentException` - if status is null

### entity

    public B entity(E entity)

  Set the entity.

  Parameters:
    `entity` - the response entity
  Returns:
    the updated instance

### type

    public B type(MediaType type)

  Set the response media type.

  Parameters:
    `type` - the media type of the response entity, if null any existing value for type will be removed
  Returns:
    the updated instance

### type

    public B type(java.lang.String type)

  Set the response media type.

  Parameters:
    `type` - the media type of the response entity, if null any existing value for type will be removed
  Returns:
    the updated instance
  Throws:
    `java.lang.IllegalArgumentException` - if type cannot be parsed

### variant

    public B variant(Variant variant)

  Set representation metadata. Equivalent to setting the values of content type, content language, and content encoding separately using the values of the variant properties.

  Parameters:
    `variant` - metadata of the response entity, a null value is equivalent to a variant with all null properties.
  Returns:
    the updated instance

### variants

    public B variants(java.util.List<Variant> variants)

  Add a Vary header that lists the available variants.

  Parameters:
    `variants` - a list of available representation variants, a null value will remove an existing value for vary.
  Returns:
    the updated instance

### language

    public B language(java.lang.String language)

  Set the language.

  Parameters:
    `language` - the language of the response entity, if null any existing value for language will be removed
  Returns:
    the updated instance

### language

    public B language(java.util.Locale language)

  Set the language.

  Parameters:
    `language` - the language of the response entity, if null any existing value for type will be removed
  Returns:
    the updated instance

### location

    public B location(java.net.URI location)

  Set the location.

  Parameters:
    `location` - the location. If a relative URI is supplied it will be converted into an absolute URI by resolving it relative to the base URI of the application (see `UriInfo#getBaseUri`). If null any existing value for location will be removed.
  Returns:
    the updated instance.

### contentLocation

    public B contentLocation(java.net.URI location)

  Set the content location.

  Parameters:
    `location` - the content location. Relative or absolute URIs may be used for the value of content location. If null any existing value for content location will be removed.
  Returns:
    the updated instance

### encoding

    public B encoding(java.lang.String encoding)

  Set the content encoding.

  Parameters:
    `encoding` - the content encoding of the response entity, if null any existing value for type will be removed
  Returns:
    the updated instance

### tag

    public B tag(EntityTag tag)

  Set an entity tag.

  Parameters:
    `tag` - the entity tag, if null any existing entity tag value will be removed.
  Returns:
    the updated instance

### tag

    public B tag(java.lang.String tag)

  Set a strong entity tag. This is a shortcut for `tag(new EntityTag(value))`.

  Parameters:
    `tag` - the string content of a strong entity tag. The JAX-RS runtime will quote the supplied value when creating the header. If null any existing entity tag value will be removed.
  Returns:
    the updated instance

### lastModified

    public B lastModified(java.util.Date lastModified)

  Set the last modified date.

  Parameters:
    `lastModified` - the last modified date, if null any existing last modified value will be removed.
  Returns:
    the updated instance

### cacheControl

    public B cacheControl(CacheControl cacheControl)

  Set the cache control.

  Parameters:
    `cacheControl` - the cache control directives, if null removes any existing cache control directives.
  Returns:
    the updated instance

### expires

    public B expires(java.util.Date expires)

  Set the expires date.

  Parameters:
    `expires` - the expiration date, if null removes any existing expires value.
  Returns:
    the updated instance

### cookie

    public B cookie(NewCookie... cookies)

  Add cookies.

  Parameters:
    `cookies` - new cookies that will accompany the response. A null value will remove all cookies, including those added via the `header(java.lang.String, java.lang.Object)` method.
  Returns:
    the updated instance

### header

    public B header(java.lang.String name,
                    java.lang.Object value)

  Add a header.

  Parameters:
    `name` - the name of the header
    `value` - the value of the header, the header will be serialized using a `RuntimeDelegate.HeaderDelegate` if one is available via `RuntimeDelegate.createHeaderDelegate(java.lang.Class)` for the class of `value` or using its `toString` method if a header delegate is not available. If `value` is null then all current headers of the same name will be removed.
  Returns:
    the updated instance.

### headerSingle

    public B headerSingle(java.lang.String name,
                          java.lang.Object value)

  Add a header or replace an existing header.

  Parameters:
    `name` - the name of the header
    `value` - the value of the header, the header will be serialized using a `RuntimeDelegate.HeaderDelegate` if one is available via `RuntimeDelegate.createHeaderDelegate(java.lang.Class)` for the class of `value` or using its `toString` method if a header delegate is not available. If `value` is null then all current headers of the same name will be removed.
  Returns:
    the updated instance.

### header

    public B header(java.lang.String name,
                    java.lang.Object value,
                    boolean single)

  Add a header.

  Parameters:
    `name` - the name of the header
    `value` - the value of the header, the header will be serialized using a `RuntimeDelegate.HeaderDelegate` if one is available via `RuntimeDelegate.createHeaderDelegate(java.lang.Class)` for the class of `value` or using its `toString` method if a header delegate is not available. If `value` is null then all current headers of the same name will be removed.
    `single` - if true then replace the header if it exists, otherwise add the header.
  Returns:
    the updated instance.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2011 Oracle Corporation. All Rights Reserved.