j_waste.network
Class FileRequestPacket

java.lang.Object
  extended byj_waste.network.Packet
      extended byj_waste.network.HeadedPacket
          extended byj_waste.network.FileRequestPacket
All Implemented Interfaces:
NetworkConstants

public class FileRequestPacket
extends HeadedPacket
implements NetworkConstants

This class represents the FileRequestPacket used in file transfers.

Version:
0.2
Author:
Mattias Ek (matek@users.sourceforge.net)

Field Summary
 
Fields inherited from class j_waste.network.HeadedPacket
iscomplete, packetData, padBytes
 
Fields inherited from class j_waste.network.Packet
packet
 
Fields inherited from interface j_waste.network.NetworkConstants
ABORT, CAP_BANDWIDTH, CAP_REMOTE_IP, CAP_SATURATION, GENERAL_TYPE_BROADCAST, GENERAL_TYPE_LOCAL, GENERAL_TYPE_ROUTED, HEADER_SIZE, MAX_BROADCAST_SIZE, MAX_ROUTED_SIZE, NO_ABORT, PREMATURE_ABORT, PRIO_CHAT, PRIO_CHAT_REPLY, PRIO_FILE_REQ_REPLY, PRIO_FILE_REQUEST, PRIO_KEYDIST, PRIO_KEYDIST_REPLY, PRIO_LCAPS, PRIO_LOCAL_SATURATE, PRIO_PING, PRIO_SEARCH, PRIO_SEARCH_REPLY, PRIO_SEARCH_USERLIST, PRIO_UPLOAD, TYPE_CHAT, TYPE_CHAT_REPLY, TYPE_FILE_REQ_REPLY, TYPE_FILE_REQUEST, TYPE_KEYDIST, TYPE_KEYDIST_REPLY, TYPE_LCAPS, TYPE_LOCAL_SATURATE, TYPE_PING, TYPE_SEARCH, TYPE_SEARCH_REPLY, TYPE_SEARCH_USERLIST, TYPE_UPLOAD
 
Constructor Summary
FileRequestPacket()
          Constructs a new FileRequestPacket.
FileRequestPacket(byte[] pkg)
          Alternative constructor.
FileRequestPacket(byte[] guid, java.lang.String DEBUG_ONLY_CONSTRUCTOR_DONT_USE)
          debug constructor, should be removed if not used anymore
 
Method Summary
 void finalizePacket()
          Finalizes the packet.
 int getAbort()
          Returns the abort flag of this packet.
 byte[] getFileGUID()
          Returns the file GUID of this packet.
 int getFileIndex()
          Returns the file index of this packet.
 byte[] getFilenameHash()
          Returns the filename hash of this packet.
 java.net.InetAddress getIP()
          Returns the IP number.
 int getNextChunk()
          Returns the number of the next chunk requested.
 int getNumberOfChunks()
          Returns the number of chunks requested.
 byte[] getOldGUID()
          Returns the old GUID of this packet.
 int getPort()
          Returns the port number.
 java.lang.String getSender()
          Returns the sender of this packet.
 void setAbort(int abort)
          Sets the abort flag of this packet.
 void setFileGUID(byte[] fileGuid)
          Sets the file GUID of this packet.
 void setFileIndex(int fileIndex)
          Sets the file index of this packet.
 void setFilenameHash(byte[] filenameHash)
          Sets the filename hash of this packet.
 void setIP(java.net.InetAddress ip)
          Sets the IP number.
 void setNextChunk(int nextChunk)
          Sets the number of the next chunk requested.
 void setNumberOfChunks(int numChunks)
          Sets the number of chunks requested.
 void setOldGUID(byte[] oldGuid)
          Sets the old GUID of this packet.
 void setPort(short port)
          Sets the port.
 void setSender(java.lang.String sender)
          Sets the sender of this packet.
 byte[] toByteArray()
          Returns a byte array representation of the packet.
 
Methods inherited from class j_waste.network.HeadedPacket
createPacket, getData, getGeneralType, getGUID, getHeader, getIntPrio, getIntType, getLength, getMD5, getPrio, getTTL, getType, setLength, setTTL
 
Methods inherited from class j_waste.network.Packet
padCD, reverseBytes, reverseInt, reverseShort, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileRequestPacket

public FileRequestPacket()
Constructs a new FileRequestPacket.


FileRequestPacket

public FileRequestPacket(byte[] pkg)
                  throws InvalidPacketException
Alternative constructor.

Parameters:
pkg - an existing byte array representation of the packet.
Throws:
InvalidPacketException - on error.

FileRequestPacket

public FileRequestPacket(byte[] guid,
                         java.lang.String DEBUG_ONLY_CONSTRUCTOR_DONT_USE)
                  throws InvalidPacketException
debug constructor, should be removed if not used anymore

Method Detail

setFileGUID

public void setFileGUID(byte[] fileGuid)
Sets the file GUID of this packet.

Parameters:
fileGuid - a byte array containing the guid of this packet.

getFileGUID

public byte[] getFileGUID()
Returns the file GUID of this packet.

Returns:
a byte array containing the guid of this packet.

setOldGUID

public void setOldGUID(byte[] oldGuid)
Sets the old GUID of this packet.

Parameters:
oldGuid - a byte array containing the old guid of this packet.

getOldGUID

public byte[] getOldGUID()
Returns the old GUID of this packet.

Returns:
a byte array containing the old guid of this packet.

setAbort

public void setAbort(int abort)
Sets the abort flag of this packet.

Parameters:
abort - An integer representing the abort status of this packet. Can have the values NO_ABORT, ABORT ot PREMATURE_ABORT.

getAbort

public int getAbort()
Returns the abort flag of this packet.

Returns:
An integer representing the abort status of this packet. Can have the values NO_ABORT, ABORT ot PREMATURE_ABORT.

setFileIndex

public void setFileIndex(int fileIndex)
Sets the file index of this packet.

Parameters:
fileIndex - The file index of this packet.

getFileIndex

public int getFileIndex()
Returns the file index of this packet.

Returns:
The file index of this packet.

setFilenameHash

public void setFilenameHash(byte[] filenameHash)
Sets the filename hash of this packet.

Parameters:
filenameHash - a 20 byte SHA-1 hash of the filename.

getFilenameHash

public byte[] getFilenameHash()
Returns the filename hash of this packet.

Returns:
The filename hash of this packet.

setSender

public void setSender(java.lang.String sender)
Sets the sender of this packet.

Parameters:
sender - A string containing the nickname of the sender of the packet.

getSender

public java.lang.String getSender()
Returns the sender of this packet.

Returns:
The sender of this packet.

setIP

public void setIP(java.net.InetAddress ip)
Sets the IP number.

Parameters:
ip - The IP number.

getIP

public java.net.InetAddress getIP()
Returns the IP number.

Returns:
The IP number.

setPort

public void setPort(short port)
Sets the port.

Parameters:
port - The port.

getPort

public int getPort()
Returns the port number.

Returns:
The port number.

setNextChunk

public void setNextChunk(int nextChunk)
Sets the number of the next chunk requested.

Parameters:
nextChunk - The number of the next chunk requested.

getNextChunk

public int getNextChunk()
Returns the number of the next chunk requested.

Returns:
The number of the next chunk requested.

setNumberOfChunks

public void setNumberOfChunks(int numChunks)
Sets the number of chunks requested.

Parameters:
numChunks - The number of chunks requested.

getNumberOfChunks

public int getNumberOfChunks()
Returns the number of chunks requested.

Returns:
The number of chunks requested.

toByteArray

public byte[] toByteArray()
Returns a byte array representation of the packet.

Overrides:
toByteArray in class HeadedPacket
Returns:
a byte array representation of the packet.

finalizePacket

public void finalizePacket()
Finalizes the packet.

Overrides:
finalizePacket in class HeadedPacket