JXTA

net.jxta.impl.content.defprovider
Class ActiveTransfer

java.lang.Object
  extended by net.jxta.impl.content.defprovider.ActiveTransfer

public class ActiveTransfer
extends Object

A node being tracked by the ActiveTransferTracker class. This class acts as a session object of sorts, maintaining client/request specific information for use in the near future.


Constructor Summary
ActiveTransfer(PeerGroup peerGroup, DefaultContentShare toShare, PipeAdvertisement destination)
          Constructs a new transfer client node.
 
Method Summary
 void close()
          Close out this session.
 DefaultContentShare getContentShare()
          Gets the ContentShare object that this transfer session is serving.
 int getData(long offset, int length, OutputStream out)
          Attempt to get the data specified for the destination given.
 OutputPipe getOutputPipe()
          Gets the output pipe for sending responses back to this client.
 boolean isIdle()
          Determines whether or not this session has been idle for too long.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActiveTransfer

public ActiveTransfer(PeerGroup peerGroup,
                      DefaultContentShare toShare,
                      PipeAdvertisement destination)
               throws IOException
Constructs a new transfer client node.

Throws:
IOException
Method Detail

getData

public int getData(long offset,
                   int length,
                   OutputStream out)
            throws IOException
Attempt to get the data specified for the destination given.

Parameters:
offset - position in the file of the beginning of the data
length - number of bytes desired
out - stream to write the data to
Returns:
negative X when X bytes have been copied and EOF has been reached, positive X when X bytes have been copied and EOF was not reached, or 0 if no bytes could be copied.
Throws:
IOException - when a problem arises working with IO

isIdle

public boolean isIdle()
Determines whether or not this session has been idle for too long.

Returns:
true if the session is idle, false if it has been reasonably active

close

public void close()
           throws IOException
Close out this session.

Throws:
IOException - when IO problem arises

getOutputPipe

public OutputPipe getOutputPipe()
Gets the output pipe for sending responses back to this client.

Returns:
output pipe

getContentShare

public DefaultContentShare getContentShare()
Gets the ContentShare object that this transfer session is serving.

Returns:
content share instance

JXSE