org.restlet.resource
Class WritableRepresentation

java.lang.Object
  extended by org.restlet.resource.Variant
      extended by org.restlet.resource.Representation
          extended by org.restlet.resource.ChannelRepresentation
              extended by org.restlet.resource.WritableRepresentation

public abstract class WritableRepresentation
extends ChannelRepresentation

Representation based on a writable NIO byte channel. The write(WritableByteChannel) method needs to be overriden in subclasses.

Author:
Jerome Louvel (contact@noelios.com)

Field Summary
 
Fields inherited from class org.restlet.resource.Variant
UNKNOWN_SIZE
 
Constructor Summary
WritableRepresentation(MediaType mediaType)
          Constructor.
 
Method Summary
 ReadableByteChannel getChannel()
          Returns a readable byte channel.
abstract  void write(WritableByteChannel writableChannel)
          Writes the representation to a byte channel.
 
Methods inherited from class org.restlet.resource.ChannelRepresentation
getStream, write
 
Methods inherited from class org.restlet.resource.Representation
getText, isAvailable, isTransient, setAvailable, setTransient
 
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

WritableRepresentation

public WritableRepresentation(MediaType mediaType)
Constructor.

Parameters:
mediaType - The representation's media type.
Method Detail

getChannel

public ReadableByteChannel getChannel()
                               throws IOException
Returns a readable byte channel. If it is supported by a file a read-only instance of FileChannel is returned.

Specified by:
getChannel in class Representation
Returns:
A readable byte channel.
Throws:
IOException

write

public abstract void write(WritableByteChannel writableChannel)
                    throws IOException
Writes the representation to a byte channel. 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:
writableChannel - A writable byte channel.
Throws:
IOException


Copyright © 2005-2007 Noelios Technologies.