me.edwards.des.net.packet
Class PacketGetData

java.lang.Object
  extended by me.edwards.des.net.packet.Packet
      extended by me.edwards.des.net.packet.PacketGetData

public class PacketGetData
extends Packet

Get Data Packet

This packet is sent to request a particular piece, or pieces, of data.

Created on: Nov 3, 2015 at 10:06:19 AM

Author:
Matthew Edwards

Nested Class Summary
 
Nested classes/interfaces inherited from class me.edwards.des.net.packet.Packet
Packet.PacketTypes
 
Field Summary
private  java.util.ArrayList<PacketInv.InvVector> vectors
           
 
Constructor Summary
PacketGetData()
          Creates new PacketGetData
PacketGetData(byte[] binary)
          Creates new PacketGetData from binary data
 
Method Summary
 void addInv(int type, java.lang.String hash)
          Adds an inventory object to this Packet.
 byte[] getBinary()
          Returns the binary payload of this Packet as a byte array.
 java.lang.String getHash(int index)
          Returns the hash of the vector at the specified index.
 int getSize()
          Returns the number of vectors in this Packet.
 int getType(int index)
          Returns the type of the vector at the specified index.
 
Methods inherited from class me.edwards.des.net.packet.Packet
getID, lookup, toHex, toString, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

vectors

private java.util.ArrayList<PacketInv.InvVector> vectors
Constructor Detail

PacketGetData

public PacketGetData()
Creates new PacketGetData


PacketGetData

public PacketGetData(byte[] binary)
Creates new PacketGetData from binary data

Parameters:
binary - Packet binary data as byte array
Method Detail

getSize

public int getSize()
Returns the number of vectors in this Packet.

Returns:
Number of vectors in this Packet

getType

public int getType(int index)
Returns the type of the vector at the specified index.

Parameters:
index - Index of inventory vector
Returns:
Type of the specified vector if the index exists, otherwise -1.

getHash

public java.lang.String getHash(int index)
Returns the hash of the vector at the specified index.

Parameters:
index - Index of inventory vector
Returns:
Hash of the specified vector if the index exists as a String, otherwise null.

addInv

public void addInv(int type,
                   java.lang.String hash)
Adds an inventory object to this Packet.

Parameters:
type - Type of data
hash - Data's 32-digit hexadecimal hash

getBinary

public byte[] getBinary()
Description copied from class: Packet
Returns the binary payload of this Packet as a byte array.

Specified by:
getBinary in class Packet
Returns:
Binary payload as a byte array