jSyncManager

org.jSyncManager.API.Protocol
Class PADPFragmentSet

java.lang.Object
  |
  +--org.jSyncManager.API.Protocol.PADPFragmentSet
All Implemented Interfaces:
java.io.Serializable

public class PADPFragmentSet
extends java.lang.Object
implements java.io.Serializable

PADPFragmentSet class. This class provides the functionality to fragment and defragment PADP packets.

Version:
$Revision: 1.6 $
Author:
Brad BARCLAY <bbarclay@jsyncmanager.org>
Last modified by: $Author: yaztromo $ on $Date: 2003/05/01 05:48:04 $.
See Also:
Serialized Form

Constructor Summary
(package private) PADPFragmentSet()
          Construct a new instance of PADPFragmentSet with default values.
(package private) PADPFragmentSet(PADP_Packet[] pkt)
          Construct a new PADP Fragment Set with the given array of PADP Packets.
 
Method Summary
(package private)  void addFragment(PADP_Packet pkt)
          Add a fragment to the end of the set.
(package private)  int bytesReceived()
          Retreives the total number of bytes received by this fragment set.
(package private) static PADPFragmentSet fragmentPacket(byte[] data, byte src, byte dest, byte transID)
          Fragments a packet of data into multiple PADP packets.
(package private)  PADP_Packet getCurrentFragment()
          Retreives the current packet from the set.
(package private)  PADP_Packet getNextFragment()
          Retreives the next fragment is this packet set, according to the fragment pointer.
(package private)  PADP_Packet getPacket(int i)
          Retreives the packet at the specified index.
(package private)  int getSize()
          Retreives the size of the packet this set represents.
(package private)  boolean hasMoreFragments()
          Tests to see if this set has more fragments that have yet to be added to the set.
(package private)  GenericPacket rebuildPacket()
          Rebuilds the packet this set represents into a single Generic Packet object.
(package private)  void setSize(int i)
          Sets the size of this fragment set.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PADPFragmentSet

PADPFragmentSet()
Construct a new instance of PADPFragmentSet with default values.

PADPFragmentSet

PADPFragmentSet(PADP_Packet[] pkt)
Construct a new PADP Fragment Set with the given array of PADP Packets.
Parameters:
pkt - an array of PADP Packets that constitute a fragment set.
Method Detail

addFragment

void addFragment(PADP_Packet pkt)
Add a fragment to the end of the set.
Parameters:
pkt - the packet to add to the back of the set.

bytesReceived

int bytesReceived()
Retreives the total number of bytes received by this fragment set.
Returns:
the total number of bytes received.

fragmentPacket

static PADPFragmentSet fragmentPacket(byte[] data,
                                      byte src,
                                      byte dest,
                                      byte transID)
                               throws PADP_PacketTooBigException
Fragments a packet of data into multiple PADP packets. This method will take an incoming packet of data to be transmitted via the PAD Protocol, and will break it up into multiple PADP Packets, stored inside a PADP Fragment Set.
Parameters:
data - the packet of data to transmit, with a maximum size of 65535 bytes.
src - the source socket for the data to be transmitted.
the - destination socket for the data to be transmitted.
transID - the transaction ID for the data to be transmitted.
Returns:
a PADP Fragment Set containing the PADP Packets for the data to be transmitted.

getCurrentFragment

PADP_Packet getCurrentFragment()
Retreives the current packet from the set. This method will retreive the packet at the current fragment pointer. If this set is empty, this method will return null.
Returns:
the packet at the current fragment pointer, or null if this set is empty.

getNextFragment

PADP_Packet getNextFragment()
Retreives the next fragment is this packet set, according to the fragment pointer. This method will retreive the next packet according to the current fragment pointer, and will then update the fragment pointer to point to this packet. If this set is empty, this method will return null.
Returns:
the next packet from the current fragment pointer, or null if this set is empty.

getPacket

PADP_Packet getPacket(int i)
Retreives the packet at the specified index. This method will return the packet at the specified index.
Parameters:
i - the packet index to retreive.
Returns:
the PADP_packet object at the specified index, or null if it doesn't exist.

getSize

int getSize()
Retreives the size of the packet this set represents.
Returns:
the size of the packet this set represents.

hasMoreFragments

boolean hasMoreFragments()
Tests to see if this set has more fragments that have yet to be added to the set.
Returns:
true if there are more fragments to be added to this set, false otherwise.

rebuildPacket

GenericPacket rebuildPacket()
Rebuilds the packet this set represents into a single Generic Packet object.
Returns:
the GenericPacket object represented by this fragment set.

setSize

void setSize(int i)
Sets the size of this fragment set.
Parameters:
i - the size of this fragment set.

jSyncManager

Copyright (c) 1999 - 2003 Brad BARCLAY and others. All Rights Reserved.