|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.restlet.resource.Variant
org.restlet.resource.Representation
public abstract class Representation
Current or intended state of a resource. For performance purpose, it is
essential that a minimal overhead occurs upon initialization. The main
overhead must only occur during invocation of content processing methods
(write, getStream, getChannel and toString).
"REST components
perform actions on a resource by using a representation to capture the
current or intended state of that resource and transferring that
representation between components. A representation is a sequence of bytes,
plus representation metadata to describe those bytes. Other commonly used but
less precise names for a representation include: document, file, and HTTP
message entity, instance, or variant." Roy T. Fielding
Field Summary |
---|
Fields inherited from class org.restlet.resource.Variant |
---|
UNKNOWN_SIZE |
Constructor Summary | |
---|---|
Representation()
Default constructor. |
|
Representation(MediaType mediaType)
Constructor. |
Method Summary | |
---|---|
abstract ReadableByteChannel |
getChannel()
Returns a channel with the representation's content. If it is supported by a file, a read-only instance of FileChannel is returned. This method is ensured to return a fresh channel for each invocation unless it is a transient representation, in which case null is returned. |
abstract InputStream |
getStream()
Returns a stream with the representation's content. |
String |
getText()
Converts the representation to a string value. |
boolean |
isAvailable()
Indicates if some fresh content is available, without having to actually call one of the content manipulation method like getStream() that would actually consume it. |
boolean |
isTransient()
Indicates if the representation's content is transient, which means that it can be obtained only once. |
void |
setAvailable(boolean available)
Indicates if some fresh content is available. |
void |
setTransient(boolean isTransient)
Indicates if the representation's content is transient. |
abstract void |
write(OutputStream outputStream)
Writes the representation to a byte stream. |
abstract void |
write(WritableByteChannel writableChannel)
Writes the representation to a byte channel. |
Methods inherited from class org.restlet.resource.Variant |
---|
getCharacterSet, getEncodings, getExpirationDate, getIdentifier, getLanguages, getMediaType, getModificationDate, getSize, getTag, setCharacterSet, setExpirationDate, setIdentifier, setIdentifier, setMediaType, setModificationDate, setSize, setTag |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Representation()
public Representation(MediaType mediaType)
mediaType
- The media type.Method Detail |
---|
public abstract ReadableByteChannel getChannel() throws IOException
IOException
public abstract InputStream getStream() throws IOException
IOException
public String getText() throws IOException
IOException
public boolean isAvailable()
public boolean isTransient()
public void setAvailable(boolean available)
available
- True if some fresh content is available.public void setTransient(boolean isTransient)
isTransient
- True if the representation's content is transient.public abstract void write(OutputStream outputStream) throws IOException
outputStream
- The output stream.
IOException
public abstract void write(WritableByteChannel writableChannel) throws IOException
writableChannel
- A writable byte channel.
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |