/** * Returns the representation wrapping the given channel. * * @param channel * The response channel. * @return The wrapping representation. */ protected Representation getRepresentation( java.nio.channels.ReadableByteChannel channel) { return new org.restlet.representation.ReadableRepresentation(channel, null); }
/** * Constructor. * * @param channel * The representation's channel. * @param mediaType * The representation's media type. * @param expectedSize * The expected stream size. */ public ReadableRepresentation(ReadableByteChannel channel, MediaType mediaType, long expectedSize) { super(mediaType); setSize(expectedSize); this.channel = channel; setAvailable(channel != null); setTransient(true); }
@Override public ReadableByteChannel getChannel() throws IOException { ReadableByteChannel result = this.channel; setAvailable(false); return result; }
@Override public void write(WritableByteChannel writableChannel) throws IOException { IoUtils.copy(getChannel(), writableChannel); }