com.limegroup.gnutella.routing
Class PatchTableMessage

java.lang.Object
  extended bycom.limegroup.gnutella.messages.Message
      extended bycom.limegroup.gnutella.routing.RouteTableMessage
          extended bycom.limegroup.gnutella.routing.PatchTableMessage
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class PatchTableMessage
extends RouteTableMessage

The PATCH route table update message. This class is as simple as possible. For example, the getData() method returns the raw bytes of the message, requiring the caller to call the getEntryBits() method to calculate the i'th patch value. (Note that this is trivial if getEntryBits() returns 8.) This is by intention, as patches are normally split into several PatchTableMessages.

See Also:
Serialized Form

Field Summary
static byte COMPRESSOR_DEFLATE
           
static byte COMPRESSOR_NONE
           
 
Fields inherited from class com.limegroup.gnutella.routing.RouteTableMessage
PATCH_VARIANT, RESET_VARIANT
 
Fields inherited from class com.limegroup.gnutella.messages.Message
F_PING, F_PING_REPLY, F_PUSH, F_QUERY, F_QUERY_REPLY, F_ROUTE_TABLE_UPDATE, F_VENDOR_MESSAGE, F_VENDOR_MESSAGE_STABLE, N_MULTICAST, N_TCP, N_UDP, N_UNKNOWN, RECORD_STATS, SOFT_MAX
 
Constructor Summary
protected PatchTableMessage(byte[] guid, byte ttl, byte hops, byte[] payload)
          Creates a new PATCH variant with data read from the network.
  PatchTableMessage(short sequenceNumber, short sequenceSize, byte compressor, byte entryBits, byte[] dataSrc, int dataSrcStart, int dataSrcStop)
          Creates a new PATCH variant from scratch, with TTL 1.
 
Method Summary
 byte getCompressor()
           
 byte[] getData()
           
 byte getEntryBits()
           
 short getSequenceNumber()
           
 short getSequenceSize()
           
 void recordDrop()
          Records the dropping of this message in statistics.
 java.lang.String toString()
           
protected  void writePayloadData(java.io.OutputStream out)
           
 
Methods inherited from class com.limegroup.gnutella.routing.RouteTableMessage
getVariant, read, stripExtendedPayload, writePayload
 
Methods inherited from class com.limegroup.gnutella.messages.Message
compareTo, getCreationTime, getFunc, getGUID, getHops, getLength, getNetwork, getPriority, getTotalLength, getTTL, hop, isMulticast, isTCP, isUDP, isUnknownNetwork, makeGuid, read, read, read, read, read, readNullTerminatedBytes, repOk, setGUID, setHops, setPriority, setTTL, updateLength, write, writeGemExtension, writeGemExtension, writeGemExtensions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COMPRESSOR_NONE

public static final byte COMPRESSOR_NONE
See Also:
Constant Field Values

COMPRESSOR_DEFLATE

public static final byte COMPRESSOR_DEFLATE
See Also:
Constant Field Values
Constructor Detail

PatchTableMessage

public PatchTableMessage(short sequenceNumber,
                         short sequenceSize,
                         byte compressor,
                         byte entryBits,
                         byte[] dataSrc,
                         int dataSrcStart,
                         int dataSrcStop)
Creates a new PATCH variant from scratch, with TTL 1. The patch data is copied from dataSrc[datSrcStart...dataSrcStop-1], inclusive.

See Also:
RouteTableMessage

PatchTableMessage

protected PatchTableMessage(byte[] guid,
                            byte ttl,
                            byte hops,
                            byte[] payload)
                     throws BadPacketException
Creates a new PATCH variant with data read from the network. The first byte is guaranteed to be PATCH_VARIANT.

Throws:
BadPacketException - the remaining values in payload are not well-formed, e.g., because it's the wrong length, the sequence size is less than the sequence number, etc.
Method Detail

writePayloadData

protected void writePayloadData(java.io.OutputStream out)
                         throws java.io.IOException
Specified by:
writePayloadData in class RouteTableMessage
Throws:
java.io.IOException

getSequenceNumber

public short getSequenceNumber()

getSequenceSize

public short getSequenceSize()

getCompressor

public byte getCompressor()

getEntryBits

public byte getEntryBits()

getData

public byte[] getData()

recordDrop

public void recordDrop()
Description copied from class: Message
Records the dropping of this message in statistics.

Specified by:
recordDrop in class Message

toString

public java.lang.String toString()
Overrides:
toString in class Message