rescuecore
Class LongUDPFragment

java.lang.Object
  extended byrescuecore.LongUDPFragment
All Implemented Interfaces:
java.lang.Comparable

public class LongUDPFragment
extends java.lang.Object
implements java.lang.Comparable

This is a piece of a LongUDPMessage


Constructor Summary
LongUDPFragment(byte[] input)
          Generate a new LongUDPFragment from some data sent by the kernal
LongUDPFragment(int id, int number, int total, byte[] data)
          Generate a new LongUDPFragment ready for sending
 
Method Summary
 int compareTo(java.lang.Object o)
           
 byte[] getData()
          Get the body of this fragment
 int getID()
          Get the message id of this fragment
 int getNumber()
          Get the sequence number of this fragment
 int getTotal()
          Get the total number of fragments in this fragment's message
 byte[] toByteArray()
          Turn this fragment into a byte array suitable for transmission to the kernal
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LongUDPFragment

public LongUDPFragment(int id,
                       int number,
                       int total,
                       byte[] data)
Generate a new LongUDPFragment ready for sending

Parameters:
id - The id of the LongUDPMessage we are sending
number - The number of this fragment
total - The total number of fragments we are sending
data - The body of this fragment

LongUDPFragment

public LongUDPFragment(byte[] input)
Generate a new LongUDPFragment from some data sent by the kernal

Parameters:
input - The raw data from the kernal. It should consist of four 16-bit numbers (magic number, id, fragment number, total number of fragments) followed by some data.
Method Detail

toString

public java.lang.String toString()

compareTo

public int compareTo(java.lang.Object o)
Specified by:
compareTo in interface java.lang.Comparable

toByteArray

public byte[] toByteArray()
Turn this fragment into a byte array suitable for transmission to the kernal

Returns:
A byte array containing the raw data of this fragment

getData

public byte[] getData()
Get the body of this fragment

Returns:
A byte array containing the body of this fragment

getID

public int getID()
Get the message id of this fragment

Returns:
This fragment's message id

getNumber

public int getNumber()
Get the sequence number of this fragment

Returns:
This fragment's sequence number

getTotal

public int getTotal()
Get the total number of fragments in this fragment's message

Returns:
The total number of fragments in this fragment's message