|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.restlet.representation.Variant
org.restlet.representation.RepresentationInfo
org.restlet.representation.Representation
org.restlet.util.WrapperRepresentation
org.restlet.representation.BufferingRepresentation
public class BufferingRepresentation
Representation capable of buffering the wrapped representation. This is
useful when you want to prevent chunk encoding from being used for dynamic
representations or when you want to reuse a transient representation several
times.
Be careful as this class could create potentially very large byte buffers in
memory that could impact your application performance.
| Field Summary |
|---|
| Fields inherited from class org.restlet.representation.Representation |
|---|
UNKNOWN_SIZE |
| Constructor Summary | |
|---|---|
BufferingRepresentation(Representation bufferedRepresentation)
Constructor. |
|
| Method Summary | |
|---|---|
long |
getAvailableSize()
Returns the size effectively available. |
protected byte[] |
getBuffer()
Returns the buffered content as an array of bytes. |
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. |
Reader |
getReader()
Returns a characters reader with the representation's content. |
long |
getSize()
Returns the total size in bytes if known, UNKNOWN_SIZE (-1) otherwise. |
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 potentially available, without having to actually call one of the content manipulation method like getStream() that would actually consume it. |
protected boolean |
isBuffered()
Indicates if the wrapped entity has been already buffered. |
protected void |
setBuffer(byte[] buffer)
Sets the buffered content as an array of bytes. |
protected void |
setBuffered(boolean buffered)
Indicates if the wrapped entity has been already buffered. |
void |
write(OutputStream outputStream)
Writes the representation to a byte stream. |
void |
write(WritableByteChannel writableChannel)
Writes the representation to a byte channel. |
void |
write(Writer writer)
Writes the representation to a characters writer. |
| Methods inherited from class org.restlet.util.WrapperRepresentation |
|---|
exhaust, getCharacterSet, getDigest, getDisposition, getEncodings, getExpirationDate, getLanguages, getLocationRef, getMediaType, getModificationDate, getRange, getRegistration, getTag, getWrappedRepresentation, isSelectable, isTransient, release, setAvailable, setCharacterSet, setDigest, setDisposition, setEncodings, setExpirationDate, setLanguages, setLocationRef, setLocationRef, setMediaType, setModificationDate, setRange, setSize, setTag, setTransient |
| Methods inherited from class org.restlet.representation.Representation |
|---|
append, hasKnownSize, isEmpty, setListener |
| Methods inherited from class org.restlet.representation.Variant |
|---|
createClientInfo, equals, includes, isCompatible, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public BufferingRepresentation(Representation bufferedRepresentation)
bufferedRepresentation - The representation to buffer.| Method Detail |
|---|
public long getAvailableSize()
RepresentationRepresentation.getSize() if no range is defined, otherwise it returns the size
of the range using Range.getSize().
getAvailableSize in class WrapperRepresentationprotected byte[] getBuffer()
public ReadableByteChannel getChannel()
throws IOException
Representation
getChannel in class WrapperRepresentationIOException
public Reader getReader()
throws IOException
Representation
getReader in class WrapperRepresentationIOExceptionpublic long getSize()
RepresentationRepresentation.getAvailableSize() method.
getSize in class WrapperRepresentationRepresentation.isEmpty()
public InputStream getStream()
throws IOException
Representation
getStream in class WrapperRepresentationIOException
public String getText()
throws IOException
Representation
getText in class WrapperRepresentationIOExceptionpublic boolean isAvailable()
Representation
isAvailable in class WrapperRepresentationprotected boolean isBuffered()
protected void setBuffer(byte[] buffer)
buffer - The buffered content as an array of bytes.protected void setBuffered(boolean buffered)
buffered - True if the wrapped entity has been already buffered.
public void write(OutputStream outputStream)
throws IOException
RepresentationOutputStream after writing to it as this will be handled by
the Restlet connectors automatically.
write in class WrapperRepresentationoutputStream - The output stream.
IOException
public void write(WritableByteChannel writableChannel)
throws IOException
Representation
write in class WrapperRepresentationwritableChannel - A writable byte channel.
IOException
public void write(Writer writer)
throws IOException
RepresentationWriter after writing to it as this will be handled
by the Restlet connectors automatically.
write in class WrapperRepresentationwriter - The characters writer.
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||