com.mindbright.ssh2
Class SSH2SFTP.SFTPPacket

java.lang.Object
  extended by com.mindbright.ssh2.SSH2DataBuffer
      extended by com.mindbright.ssh2.SSH2SFTP.SFTPPacket
All Implemented Interfaces:
NIOCallback
Enclosing class:
SSH2SFTP

protected static final class SSH2SFTP.SFTPPacket
extends SSH2DataBuffer
implements NIOCallback

Handles sftp data packets. Contains functions to read and write the sftp types.


Field Summary
 
Fields inherited from class com.mindbright.ssh2.SSH2DataBuffer
BOOLEAN_FALSE, BOOLEAN_TRUE, data, rPos, wPos
 
Constructor Summary
SSH2SFTP.SFTPPacket()
           
 
Method Summary
 void asyncRead(NonBlockingInput in, SSH2SFTP.Callback callback)
           
 void completed(java.nio.ByteBuffer buf)
          Called once the network read operation has been completed
 void connected(boolean timeout)
          Called once the connection has been established (assuming interest for this has been registered by calling the NotifyWhenConnected method of Switchboard).
 void connectionFailed(java.lang.Exception e)
          Called if the connection failed (assuming interest for this has been registered by calling the NotifyWhenConnected method of Switchboard).
 void failsafeReadFrom(NonBlockingInput in)
          Failsafe read method.
 int getId()
           
 int getLength()
           
 int getType()
           
 SSH2SFTP.FileAttributes readAttrs()
           
 void readFailed(java.lang.Exception e)
          Called if the read failed
 void readFrom(NonBlockingInput in)
           
 SSH2SFTP.FileSystemAttributes readFSAttrs()
           
 void reset(int type, int id)
           
 void writeAttrs(SSH2SFTP.FileAttributes attrs)
           
 void writeFailed()
          Called if the write failed
 void writeTo(NonBlockingOutput out)
           
 
Methods inherited from class com.mindbright.ssh2.SSH2DataBuffer
getData, getMaxReadSize, getMaxSize, getMaxWriteSize, getRPos, getWPos, readBigInt, readBigIntBits, readBoolean, readByte, readInt, readJavaString, readLong, readRaw, readRaw, readRestRaw, readString, readString, readUInt, reset, resize, setData, setRPos, setWPos, writeBigInt, writeBigIntBits, writeBoolean, writeByte, writeInt, writeInt, writeLong, writeRaw, writeRaw, writeString, writeString, writeString, writeUTF8String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SSH2SFTP.SFTPPacket

public SSH2SFTP.SFTPPacket()
Method Detail

reset

public void reset(int type,
                  int id)

getType

public int getType()

getId

public int getId()

getLength

public int getLength()

writeAttrs

public void writeAttrs(SSH2SFTP.FileAttributes attrs)

readAttrs

public SSH2SFTP.FileAttributes readAttrs()

readFSAttrs

public SSH2SFTP.FileSystemAttributes readFSAttrs()

failsafeReadFrom

public void failsafeReadFrom(NonBlockingInput in)
                      throws SSH2SFTP.SFTPException
Failsafe read method. Tries to read a packet from the given stream. but does ignore stuff which does not look like a packet. The algorithm is that a probable packet starts with two bytes containing zeros.

This is useful when reading the first version packet which is small but may be, on broken systems, preceded by some ascii characters.

Parameters:
in - Stream to read data from
Throws:
SSH2SFTP.SFTPException

readFrom

public void readFrom(NonBlockingInput in)
              throws SSH2SFTP.SFTPException
Throws:
SSH2SFTP.SFTPException

asyncRead

public void asyncRead(NonBlockingInput in,
                      SSH2SFTP.Callback callback)
               throws SSH2SFTP.SFTPException
Throws:
SSH2SFTP.SFTPException

writeTo

public void writeTo(NonBlockingOutput out)
             throws SSH2SFTP.SFTPException
Throws:
SSH2SFTP.SFTPException

completed

public void completed(java.nio.ByteBuffer buf)
Description copied from interface: NIOCallback
Called once the network read operation has been completed

Specified by:
completed in interface NIOCallback
Parameters:
buf - the buffer provided to the read call

readFailed

public void readFailed(java.lang.Exception e)
Description copied from interface: NIOCallback
Called if the read failed

Specified by:
readFailed in interface NIOCallback

writeFailed

public void writeFailed()
Description copied from interface: NIOCallback
Called if the write failed

Specified by:
writeFailed in interface NIOCallback

connected

public void connected(boolean timeout)
Description copied from interface: NIOCallback
Called once the connection has been established (assuming interest for this has been registered by calling the NotifyWhenConnected method of Switchboard).

Specified by:
connected in interface NIOCallback
Parameters:
timeout - true if the connection attempt timed out

connectionFailed

public void connectionFailed(java.lang.Exception e)
Description copied from interface: NIOCallback
Called if the connection failed (assuming interest for this has been registered by calling the NotifyWhenConnected method of Switchboard).

Specified by:
connectionFailed in interface NIOCallback
Parameters:
e - the exception the connection failed with.