com.sun.jersey.atom.abdera
Class ContentHelper

java.lang.Object
  extended by com.sun.jersey.atom.abdera.ContentHelper

public class ContentHelper
extends java.lang.Object

Helper class to assist in serializing and deserializing Java entities as XML that will be transferred through the content element of an Atom Entry instance. A configured instance of this class can be made available in a resource class as follows:

   @Context
   private ContentHelper contentHelper;
 


Constructor Summary
ContentHelper(javax.ws.rs.ext.Providers providers)
          Construct a configured instance of this helper.
 
Method Summary
<T> T
getContentEntity(org.apache.abdera.model.Entry entry, java.lang.Class<T> clazz)
          Deserialize the content element of the specified entry, and transform it back into an appropriate Java object.
<T> T
getContentEntity(org.apache.abdera.model.Entry entry, javax.ws.rs.core.MediaType mediaType, java.lang.Class<T> clazz)
          Deserialize the content element of the specified entry, and transform it back into an appropriate Java object.
 void setContentEntity(org.apache.abdera.model.Entry entry, javax.ws.rs.core.MediaType mediaType, java.lang.Object entity)
          Serialize the specified entity as the content element of the specified entry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentHelper

public ContentHelper(javax.ws.rs.ext.Providers providers)

Construct a configured instance of this helper.

Parameters:
providers - Providers for this application
Method Detail

getContentEntity

public <T> T getContentEntity(org.apache.abdera.model.Entry entry,
                              java.lang.Class<T> clazz)

Deserialize the content element of the specified entry, and transform it back into an appropriate Java object. The media type used for selecting an appropriate Provider will be acquired from the type attribute of the content element.

Parameters:
entry - Entry whose content element is to be processed
clazz - Class of the object to be returned
Throws:
java.lang.IllegalArgumentException - if the specified entry does not contain a valid content element

getContentEntity

public <T> T getContentEntity(org.apache.abdera.model.Entry entry,
                              javax.ws.rs.core.MediaType mediaType,
                              java.lang.Class<T> clazz)

Deserialize the content element of the specified entry, and transform it back into an appropriate Java object.

Parameters:
entry - Entry whose content element is to be processed
mediaType - MediaType to use when selecting an appropriate provider
clazz - Class of the object to be returned
Throws:
java.lang.IllegalArgumentException - if the specified entry does not contain a valid content element

setContentEntity

public void setContentEntity(org.apache.abdera.model.Entry entry,
                             javax.ws.rs.core.MediaType mediaType,
                             java.lang.Object entity)

Serialize the specified entity as the content element of the specified entry. The selected provider MUST produce an XML representation.

Parameters:
entry - Entry whose content element is to be set
mediaType - MediaType to pass as the type attribute of the content element (also used to select an appropriate Provider)
entity - Entity to be serialized


Copyright © 2011 Sun Microsystems, Inc. All Rights Reserved.