org.restlet.resource
Class ObjectRepresentation<T extends java.io.Serializable>

java.lang.Object
  extended by org.restlet.resource.Variant
      extended by org.restlet.resource.Representation
          extended by org.restlet.resource.StreamRepresentation
              extended by org.restlet.resource.OutputRepresentation
                  extended by org.restlet.resource.ObjectRepresentation<T>
Type Parameters:
T - The class to serialize, see Serializable

public class ObjectRepresentation<T extends java.io.Serializable>
extends OutputRepresentation

Representation based on a serializable Java object.

Author:
Jerome Louvel

Field Summary
 
Fields inherited from class org.restlet.resource.Representation
UNKNOWN_SIZE
 
Constructor Summary
ObjectRepresentation(Representation serializedRepresentation)
          Constructor reading the object from a serialized representation.
ObjectRepresentation(T object)
          Constructor
 
Method Summary
 T getObject()
          Returns the represented object.
 void release()
          Releases the represented object.
 void setObject(T object)
          Sets the represented object.
 void write(java.io.OutputStream outputStream)
          Writes the representation to a byte stream.
 
Methods inherited from class org.restlet.resource.OutputRepresentation
getStream
 
Methods inherited from class org.restlet.resource.StreamRepresentation
getChannel, getReader, write, write
 
Methods inherited from class org.restlet.resource.Representation
checkDigest, checkDigest, computeDigest, createEmpty, exhaust, getAvailableSize, getDigest, getDownloadName, getExpirationDate, getModificationDate, getRange, getSize, getTag, getText, isAvailable, isDownloadable, isTransient, setAvailable, setDigest, setDownloadable, setDownloadName, setExpirationDate, setModificationDate, setRange, setSize, setTag, setTransient
 
Methods inherited from class org.restlet.resource.Variant
getCharacterSet, getEncodings, getIdentifier, getLanguages, getMediaType, setCharacterSet, setEncodings, setIdentifier, setIdentifier, setLanguages, setMediaType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectRepresentation

public ObjectRepresentation(Representation serializedRepresentation)
                     throws java.io.IOException,
                            java.lang.ClassNotFoundException,
                            java.lang.IllegalArgumentException
Constructor reading the object from a serialized representation. This representation must have the proper media type: "application/x-java-serialized-object".

Parameters:
serializedRepresentation - The serialized representation.
Throws:
java.io.IOException
java.lang.ClassNotFoundException
java.lang.IllegalArgumentException

ObjectRepresentation

public ObjectRepresentation(T object)
Constructor

Parameters:
object - The serializable object.
Method Detail

getObject

public T getObject()
                                         throws java.io.IOException
Returns the represented object.

Returns:
The represented object.
Throws:
java.io.IOException

release

public void release()
Releases the represented object.

Overrides:
release in class OutputRepresentation

setObject

public void setObject(T object)
Sets the represented object.

Parameters:
object - The represented object.

write

public void write(java.io.OutputStream outputStream)
           throws java.io.IOException
Description copied from class: Representation
Writes the representation to a byte stream. This method is ensured to write the full content for each invocation unless it is a transient representation, in which case an exception is thrown.

Specified by:
write in class Representation
Parameters:
outputStream - The output stream.
Throws:
java.io.IOException


Copyright © 2005-2008 Noelios Technologies.