net.petterroea.starterkit
Class Packet

java.lang.Object
  extended by net.petterroea.starterkit.Packet

public class Packet
extends java.lang.Object

Basic packet class.

This is used for recieving and sending packets

Author:
petterroea

Nested Class Summary
static class Packet.Packettype
          Packet types
 
Field Summary
private  java.lang.String[] contents
          Contents of the packet
 java.lang.String prefix
          The prefix
 Packet.Packettype type
          Type, used for checking
 
Constructor Summary
Packet(java.lang.String raw)
          Constructor that allows you to enter the raw code.
Packet(java.lang.String[] temp)
          Constructor for a packet.
Packet(java.lang.String[] temp, Packet.Packettype type)
          Constructor for a packet.
Packet(java.lang.String raw, Packet.Packettype type)
          Constructor that allows you to enter the raw code.
 
Method Summary
 java.lang.String[] getEntirePacket()
          Get the entire packet data array
 int getLength()
          Get the length of the packet data array
 java.lang.String getPacketDataAt(int index)
          Get the packet data at the following index
 java.lang.String getRaw()
          Get the raw data of this packet
 void setPacketDataAt(int index, java.lang.String data)
          Sets packet data at the following index
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

contents

private java.lang.String[] contents
Contents of the packet


prefix

public java.lang.String prefix
The prefix


type

public Packet.Packettype type
Type, used for checking

Constructor Detail

Packet

public Packet(java.lang.String[] temp,
              Packet.Packettype type)
Constructor for a packet. This is used for recieving, not by you.

Parameters:
temp - The data in the packet
type - The packet type

Packet

public Packet(java.lang.String raw,
              Packet.Packettype type)
Constructor that allows you to enter the raw code. Use this for sending

Parameters:
raw - Raw data that is not splitted
type - The packet type

Packet

public Packet(java.lang.String[] temp)
Constructor for a packet. This is used for recieving, not by you.

Parameters:
temp - The data in the packet

Packet

public Packet(java.lang.String raw)
Constructor that allows you to enter the raw code. This is used for recieving

Parameters:
raw - Raw data that is not splitted
Method Detail

getRaw

public java.lang.String getRaw()
Get the raw data of this packet

Returns:
The raw data

getEntirePacket

public java.lang.String[] getEntirePacket()
Get the entire packet data array

Returns:
The array of data

getPacketDataAt

public java.lang.String getPacketDataAt(int index)
Get the packet data at the following index

Parameters:
index - The index you want packet data from
Returns:
The packet data at index.

getLength

public int getLength()
Get the length of the packet data array

Returns:
The length of the packet data array

setPacketDataAt

public void setPacketDataAt(int index,
                            java.lang.String data)
Sets packet data at the following index

Parameters:
index - The index to set data from
data - The data to insert into the array at position index