peer2me.domain
Class GroupSyncPackage

java.lang.Object
  extended bypeer2me.domain.DataPackage
      extended bypeer2me.domain.GroupSyncPackage

public class GroupSyncPackage
extends DataPackage

A GroupSyncPackage is a package used internally in the framework to synchronize the groups containing the participants. The participant performing the groupsync uses its own group as content of the package. All the receivers synchronizes their groups based on the information found in the GroupSyncPackage.

Author:
Torbjørn Vatn & Steinar A. Hestnes

Field Summary
 
Fields inherited from class peer2me.domain.DataPackage
FILE_PACKAGE, GROUP_SYNC_PACKAGE, log, TEXT_PACKAGE
 
Constructor Summary
GroupSyncPackage()
          Constructor used to create an empty GroupSyncPackage object to fill with the parseBytes() method
GroupSyncPackage(Node sender, java.lang.String[] recipients, Node[] participatingNodes)
          Constructor
 
Method Summary
 Node[] getParticipants()
          This method returns a list of the nodes that are participating in the network (group)
 void parseBytes(byte[] data)
          This method parses the content of the byte array (byte[]) back into a GroupSyncPackage object
 byte[] toSendableFormat()
          This method transforms this groupsync package into a byte array (byte[]) that is possible to send over a network stream
 
Methods inherited from class peer2me.domain.DataPackage
getRecipients, getSender, getType, setRecipients, setSender
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupSyncPackage

public GroupSyncPackage(Node sender,
                        java.lang.String[] recipients,
                        Node[] participatingNodes)
Constructor

Parameters:
sender - A node object representing the sender node
recipients - The addresses to the recipients of the groupsync package
participatingNodes - A hashtable with node addresses as keys and names as values

GroupSyncPackage

public GroupSyncPackage()
Constructor used to create an empty GroupSyncPackage object to fill with the parseBytes() method

Method Detail

getParticipants

public Node[] getParticipants()
This method returns a list of the nodes that are participating in the network (group)

Returns:
A list of participating nodes

toSendableFormat

public byte[] toSendableFormat()
This method transforms this groupsync package into a byte array (byte[]) that is possible to send over a network stream

Specified by:
toSendableFormat in class DataPackage
Returns:
The byte[] representation of the groupsync package

parseBytes

public void parseBytes(byte[] data)
This method parses the content of the byte array (byte[]) back into a GroupSyncPackage object

Specified by:
parseBytes in class DataPackage
Parameters:
data - The byte[] containing the data representing the GroupSyncPackage object