peer2me.domain
Class TextPackage

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

public class TextPackage
extends DataPackage

This class represents a data package containing text that should be sent over the network.

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
TextPackage()
          Constructor used to create an empty TextPackage object to fill with the parseBytes() method
TextPackage(Node sender, java.lang.String[] recipients, java.lang.String content)
          Constructor
 
Method Summary
 java.lang.String getContent()
          This method returns the text content of this TextPackage
 void parseBytes(byte[] data)
          This method parses the content of the byte array (byte[]) back into a TextPackage object
 byte[] toSendableFormat()
          This method transforms this text 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

TextPackage

public TextPackage(Node sender,
                   java.lang.String[] recipients,
                   java.lang.String content)
Constructor

Parameters:
sender - A node object representing the sender node
recipients - The addresses to the recipients of the text package
content - The String to be sent

TextPackage

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

Method Detail

getContent

public java.lang.String getContent()
This method returns the text content of this TextPackage

Returns:
The content

toSendableFormat

public byte[] toSendableFormat()
This method transforms this text 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 text package

parseBytes

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

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