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.core.provider
Class EntityHolder<T>

    java.lang.Object
      com.sun.jersey.core.provider.EntityHolder<T>

    public class EntityHolder<T>

extends java.lang.Object

A holder for an entity of a request consumed by the server or a response consumed by a client.

Some clients/servers may send requests/responses with no entity or an entity (for example WebDAV clients). To support such request or responses The `EntityHolder` type may be used where the actual type of the entity is declared as a type parameter.

For example a POST method that consumes a specific JAXB object, `MyJAXBObject`, can determine if the request contained the JAXB object or the request contained no entity, as follows:

>          @POST
>          @Consumes("text/plain")
>          public void post(EntityHolder<MyJAXBObject> s) {
>              if (s.hasEntity()) {
>                  MyJAXBObject entity = s.getEntity();
>              } else {
>                ...
>              }
>          }

Author:
  Paul.Sandoz@Sun.Com

Constructor Summary
`EntityHolder()` Create an entity holder containing no entity.
`EntityHolder(T t)` Create an entity holder containing an entity.

Method Summary
`T` | `getEntity()` Get the entity.
`boolean` | `hasEntity()`

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

Constructor Detail

### EntityHolder

    public EntityHolder()

  Create an entity holder containing no entity.

### EntityHolder

    public EntityHolder(T t)

  Create an entity holder containing an entity.

  Parameters:
    `t` - the entity.

Method Detail

### hasEntity

    public boolean hasEntity()

  Returns:
    true if there is an entity present, otherwise false.

### getEntity

    public T getEntity()

  Get the entity.

  Returns:
    the entity if present, otherwise null if the entity is not present.

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.