Secure iNet Factory

com.jscape.inet.sftp
Class PacketReader

java.lang.Object
  extended by com.jscape.inet.sftp.PacketReader

public final class PacketReader
extends java.lang.Object

The SFTP packet reader. Restores SFTP packets from the input stream.

Author:
Alex Usun

Constructor Summary
PacketReader(java.io.InputStream in)
          Creates a new packet reader instance.
PacketReader(java.io.InputStream in, java.util.Map packets)
          Creates a new packet reader instance.
 
Method Summary
 void close()
          Closes the current reader and releases all associated resources.
 boolean isClosed()
          Checks if the current reader is closed.
 boolean knowsPacket(int type)
          Checks if reader can read packets of the specified type.
 SftpPacket readPacket(java.lang.String charset)
          Reads the packet from the stream.
 void registerPacket(int type, java.lang.Class packetClass)
          Adds packet class to the reader.
 void unregisterPacket(int type)
          Removes packet from the reader.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PacketReader

public PacketReader(java.io.InputStream in)
Creates a new packet reader instance.

Parameters:
in - the base input stream

PacketReader

public PacketReader(java.io.InputStream in,
                    java.util.Map packets)
Creates a new packet reader instance.

Parameters:
in - the base input stream
packets - packets to read
Method Detail

registerPacket

public void registerPacket(int type,
                           java.lang.Class packetClass)
Adds packet class to the reader.

Parameters:
type - a packet type
packetClass - a packet class

unregisterPacket

public void unregisterPacket(int type)
Removes packet from the reader.

Parameters:
type - a packet type to remove

knowsPacket

public boolean knowsPacket(int type)
Checks if reader can read packets of the specified type.

Parameters:
type - a packet type
Returns:
true if the current reader can read these packets; otherwise

close

public void close()
Closes the current reader and releases all associated resources.


isClosed

public boolean isClosed()
Checks if the current reader is closed.

Returns:
true if the reader is closed; false otherwise

readPacket

public SftpPacket readPacket(java.lang.String charset)
                      throws SftpException
Reads the packet from the stream.

Returns:
a readed packet
Throws:
SftpException - if I/O error occurs

Secure iNet Factory

Copyright © JSCAPE LLC. 1999-2011. All Rights Reserved