j_waste.network
Class LocalCapsPacket

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

public class LocalCapsPacket
extends HeadedPacket
implements NetworkConstants

This is the class for the Local Caps packet type.

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
LocalCapsPacket()
           
LocalCapsPacket(byte[] packet)
          Constructs a new LocalCapsPacket by parsing the specified byte array;
LocalCapsPacket(byte[] guid, java.lang.String debug_only)
          Debug constructor.
 
Method Summary
 boolean addCap(int cap, int value)
          Adds a cap with associated value to this LocalCapsPacket.
 void finalizePacket()
          Finalizes this packet.
 int getCap(int index)
          Returns the cap at the specified index.
 int getNumCaps()
          Returns the number of caps in this packet.
 int getValue(int index)
          Returns the value of the cap at the specified index.
 byte[] toByteArray()
          Returns a byte array representation of this 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

LocalCapsPacket

public LocalCapsPacket()

LocalCapsPacket

public LocalCapsPacket(byte[] packet)
                throws InvalidPacketException
Constructs a new LocalCapsPacket by parsing the specified byte array;

Parameters:
packet - The byte array to be parsed.

LocalCapsPacket

public LocalCapsPacket(byte[] guid,
                       java.lang.String debug_only)
Debug constructor.

Parameters:
guid - a GUID.
debug_only - String indicating debug.
Method Detail

addCap

public boolean addCap(int cap,
                      int value)
Adds a cap with associated value to this LocalCapsPacket.

Parameters:
cap - The type of cap to be added.
value - The value of the cap.
Returns:
Returns true if the cap was added successfully, false otherwise.

getNumCaps

public int getNumCaps()
Returns the number of caps in this packet.

Returns:
The number of caps in this packet.

getCap

public int getCap(int index)
Returns the cap at the specified index.

Parameters:
index - The index of the cap.
Returns:
The cap at the specified index.

getValue

public int getValue(int index)
Returns the value of the cap at the specified index.

Parameters:
index - The index of the cap associated with the value.
Returns:
The value of the cap at teh specified index.

toByteArray

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

Overrides:
toByteArray in class HeadedPacket
Returns:
The byte array representation of this packet.

finalizePacket

public void finalizePacket()
Finalizes this packet.

Overrides:
finalizePacket in class HeadedPacket