peer2me.domain
Class FilePackage

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

public class FilePackage
extends DataPackage

This class represents a data package containing metadata about a file of some sort that should be sent over the network. The package contains the file path and length of the file to transfer, so that the receiver can handle the incoming stream of data and transform it back into a copy of the file.

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

FilePackage

public FilePackage(Node sender,
                   java.lang.String[] recipients,
                   java.lang.String filePath)
Constructor

Parameters:
sender - A node object representing the sender node
recipients - The addresses to the recipients of the file package
filePath - The path of the file to be sent

FilePackage

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

Method Detail

getFilePath

public java.lang.String getFilePath()
This method returns the file path of this FilePackage

Returns:
The file path

getFileSize

public long getFileSize()
This method returns the file size of this FilePackage

Returns:
The file size

toSendableFormat

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

parseBytes

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

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