org.objectweb.jonathan.protocols.tcpip
Class TcpIpChunkProvider

java.lang.Object
  extended byorg.objectweb.jonathan.resources.api.Chunk
      extended byorg.objectweb.jonathan.protocols.tcpip.TcpIpChunkProvider
All Implemented Interfaces:
ChunkProvider

public class TcpIpChunkProvider
extends Chunk
implements ChunkProvider

TcpIpChunkProvider is a ChunkProvider implementation encapsulating a socket input stream.


Field Summary
 
Fields inherited from class org.objectweb.jonathan.resources.api.Chunk
data, next, offset, top
 
Method Summary
 void close()
          Closes the chunk provider.
 Chunk duplicate()
          Duplicates the whole chunk.
 Chunk duplicate(int off, int t)
          Partially duplicates this chunk.
protected  void finalize()
           
 Chunk prepare()
          Returns a chunk to read data from.
 void release()
          Releases the chunk.
 
Methods inherited from class org.objectweb.jonathan.resources.api.Chunk
toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

prepare

public Chunk prepare()
              throws org.objectweb.jonathan.apis.kernel.JonathanException
Description copied from interface: ChunkProvider
Returns a chunk to read data from.

When done with the chunk, its user must update its offset and top members and release it.

ChunkProviders should not be used concurrently.

Specified by:
prepare in interface ChunkProvider
Returns:
a chunk;
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException - if no chunk can be provided.

close

public void close()
Description copied from interface: ChunkProvider
Closes the chunk provider. This method must be called if the target provider is no longer used.

Specified by:
close in interface ChunkProvider

finalize

protected void finalize()

duplicate

public Chunk duplicate()
                throws org.objectweb.jonathan.apis.kernel.JonathanException
Description copied from class: Chunk
Duplicates the whole chunk.

The default implementation copies the buffer, and creates a new chunk with it.

Overrides:
duplicate in class Chunk
Returns:
a copy of this chunk.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException

duplicate

public Chunk duplicate(int off,
                       int t)
                throws org.objectweb.jonathan.apis.kernel.JonathanException
Description copied from class: Chunk
Partially duplicates this chunk. 'offset' must be greater than the target chunk's offset, 'top' must be less or equal than the target's top.

The default implementation copies the appropriate portion of the buffer, and creates a new chunk with it.

Overrides:
duplicate in class Chunk
Parameters:
off - the offset of the chunk copy.
t - the top of the chunk copy.
Returns:
a chunk containing the specified part of the target chunk.
Throws:
org.objectweb.jonathan.apis.kernel.JonathanException

release

public void release()
Description copied from class: Chunk
Releases the chunk. The data of a chunk may be obtained from managed buffers. It may thus be necessary to tell when the data encapsulated by a chunk may be reused.

The default implementation resets offset and top to 0.

Overrides:
release in class Chunk