org.restlet.engine.io
Class BufferingRepresentation

java.lang.Object
  extended by org.restlet.representation.Variant
      extended by org.restlet.representation.RepresentationInfo
          extended by org.restlet.representation.Representation
              extended by org.restlet.util.WrapperRepresentation
                  extended by org.restlet.engine.io.BufferingRepresentation

public class BufferingRepresentation
extends WrapperRepresentation

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.

Author:
Thierry Boileau

Field Summary
 
Fields inherited from class org.restlet.representation.Representation
UNKNOWN_SIZE
 
Constructor Summary
BufferingRepresentation(Representation bufferedRepresentation)
          Constructor.
 
Method Summary
 long getAvailableSize()
           
protected  byte[] getBuffer()
          Returns the buffered content as an array of bytes.
 ReadableByteChannel getChannel()
           
 Reader getReader()
           
 long getSize()
           
 InputStream getStream()
           
 String getText()
           
 boolean isAvailable()
           
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)
           
 void write(WritableByteChannel writableChannel)
           
 void write(Writer 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

BufferingRepresentation

public BufferingRepresentation(Representation bufferedRepresentation)
Constructor.

Parameters:
bufferedRepresentation - The representation to buffer.
Method Detail

getAvailableSize

public long getAvailableSize()
Overrides:
getAvailableSize in class WrapperRepresentation

getBuffer

protected byte[] getBuffer()
Returns the buffered content as an array of bytes.

Returns:
The buffered content as an array of bytes.

getChannel

public ReadableByteChannel getChannel()
                               throws IOException
Overrides:
getChannel in class WrapperRepresentation
Throws:
IOException

getReader

public Reader getReader()
                 throws IOException
Overrides:
getReader in class WrapperRepresentation
Throws:
IOException

getSize

public long getSize()
Overrides:
getSize in class WrapperRepresentation

getStream

public InputStream getStream()
                      throws IOException
Overrides:
getStream in class WrapperRepresentation
Throws:
IOException

getText

public String getText()
               throws IOException
Overrides:
getText in class WrapperRepresentation
Throws:
IOException

isAvailable

public boolean isAvailable()
Overrides:
isAvailable in class WrapperRepresentation

isBuffered

protected boolean isBuffered()
Indicates if the wrapped entity has been already buffered.

Returns:
True if the wrapped entity has been already buffered.

setBuffer

protected void setBuffer(byte[] buffer)
Sets the buffered content as an array of bytes.

Parameters:
buffer - The buffered content as an array of bytes.

setBuffered

protected void setBuffered(boolean buffered)
Indicates if the wrapped entity has been already buffered.

Parameters:
buffered - True if the wrapped entity has been already buffered.

write

public void write(OutputStream outputStream)
           throws IOException
Overrides:
write in class WrapperRepresentation
Throws:
IOException

write

public void write(WritableByteChannel writableChannel)
           throws IOException
Overrides:
write in class WrapperRepresentation
Throws:
IOException

write

public void write(Writer writer)
           throws IOException
Overrides:
write in class WrapperRepresentation
Throws:
IOException


Copyright © 2005-2013 Restlet.