Synergy Home Page

au.edu.swin.synergy.lib
Class BFile

java.lang.Object
  |
  +--au.edu.swin.synergy.lib.BFile

public class BFile
extends Object
implements Serializable

Encapsulates a file(s) which may be sent accross the network. File name(s) are passed through to the constructor which then opens and compresses to allow minimal tramit delay over network. When this class is received on the other end it is to be decompressed in working directory.

Author:
Christian Karolos
Copyright Belongs To:
Copyright (c) 1999
See Also:
Serialized Form

Field Summary
static int kDefaultCompressionRate
           
static int kMaxCompressionRate
           
static int kMinCompressionRate
           
 
Constructor Summary
BFile(File[] fileGroup, int compressionRate)
          Constructor which registers files to be compressed at a specified rate.
BFile(File file, int compressionRate)
          Constructor which registers the file to be compressed at a specified rate.
 
Method Summary
 boolean compress()
          Compresses file(s) specified when this object was created.
 boolean createZipFile(String fName)
          Mainly for testing purposes will write whatever is contained in our buffer to file of users choice.
 boolean expand()
          Expands file(s) registered with this class to working directory.
 boolean expand(File f)
          Expands file(s) registered with this class into directory of users choice.
 String getFileName()
          If only one file has been compressed, return it's file name.
 BStringList getFileNames()
          Returns file names of all file compressed in this object.
 boolean multipleFiles()
          Signifies whether multiple files have been compressed.
 void setCompressionRate(int rate)
          Sets the rate at which file(s) are to be compressed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

kMinCompressionRate

public static final int kMinCompressionRate

kMaxCompressionRate

public static final int kMaxCompressionRate

kDefaultCompressionRate

public static final int kDefaultCompressionRate
Constructor Detail

BFile

public BFile(File file,
             int compressionRate)
Constructor which registers the file to be compressed at a specified rate.
Parameters:
fileName - Name of file to be compressed
compressionRate - Rate at which file is to be compressed. Please complete the missing tags for BFile

BFile

public BFile(File[] fileGroup,
             int compressionRate)
Constructor which registers files to be compressed at a specified rate.
Parameters:
fileGroup - Group of files to be compressed
compressionRate - Rate at which file is to be compressed.
Method Detail

getFileNames

public BStringList getFileNames()
Returns file names of all file compressed in this object.
Returns:
List of file names.
Pre Condition:
Files have been compressed and set.

getFileName

public String getFileName()
If only one file has been compressed, return it's file name.
Returns:
Name of compressed file.
Pre Condition:
File has been set.

setCompressionRate

public void setCompressionRate(int rate)
Sets the rate at which file(s) are to be compressed.
Parameters:
rate - User specified compression rate.
Modifies:
compressionRate

multipleFiles

public boolean multipleFiles()
Signifies whether multiple files have been compressed.
Returns:
True if many files have been compressed.

compress

public boolean compress()
Compresses file(s) specified when this object was created. Then writes to our file buffer whatever has been compressed.
Returns:
Boolean indicating whether the compression process went to plan
Throws:
IOException -  
Pre Condition:
File name has been set.
Post Condition:
File compressed.
Modifies:
fileBuffer, fileCompressed

createZipFile

public boolean createZipFile(String fName)
Mainly for testing purposes will write whatever is contained in our buffer to file of users choice.
Parameters:
fName - Name of file compressed data is written to
Returns:
Boolean signifing is zip successfully created
Throws:
IOException -  
Pre Condition:
File(s) must have been compressed
Post Condition:
File compressed and file created.

expand

public boolean expand()
Expands file(s) registered with this class to working directory.
Returns:
Boolean indicating success of decompression
Throws:
FileNotFoundException -  
IOException -  
Pre Condition:
CompressFile () must have been called
Post Condition:
File expanded in working directory.

expand

public boolean expand(File f)
Expands file(s) registered with this class into directory of users choice.
Parameters:
f - File path to save file.
Returns:
Boolean indicating success of decompression
Throws:
FileNotFoundException -  
IOException -  
Pre Condition:
CompressFile () must have been called
Post Condition:
File expanded in path of users choice.

Synergy Home Page