Babylon Java Chat

Class BabylonFileTransfer

java.lang.Object
  extended by java.lang.Thread
      extended by BabylonFileTransfer
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
BabylonClientFileTransfer, BabylonServerFileTransfer

public abstract class BabylonFileTransfer
extends java.lang.Thread

An abstract class for file transfers by the client or server. Used as a superclass for BabylonServerFileTransfer and BabylonClientFileTransfer, this class contains common data items and methods for reading and writing the file.

Author:
Andy McLaughlin

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  int blockSize
           
protected static int DEFAULT_BLOCKSIZE
           
protected  int expireMins
           
protected  long expiryTime
           
protected  java.lang.String fileName
           
protected  boolean receivedAll
           
protected  int receivedBlocks
           
protected  java.io.File tmpFile
           
protected  int totalBlocks
           
protected  long totalSize
           
protected  java.io.RandomAccessFile transFile
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
BabylonFileTransfer(java.lang.String fn, long ts, int tb, int bs, int minutes)
           
 
Method Summary
protected  byte[] getFileBlock(int blockNumber)
          Read the requested block number from the file and return the data.
protected  void putFileBlock(int blockNumber, byte[] data)
          Write the requested block number to the file using the supplied data.
abstract  void run()
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_BLOCKSIZE

protected static final int DEFAULT_BLOCKSIZE
See Also:
Constant Field Values

fileName

protected java.lang.String fileName

totalSize

protected long totalSize

totalBlocks

protected int totalBlocks

blockSize

protected int blockSize

expireMins

protected int expireMins

expiryTime

protected long expiryTime

tmpFile

protected java.io.File tmpFile

transFile

protected java.io.RandomAccessFile transFile

receivedBlocks

protected int receivedBlocks

receivedAll

protected boolean receivedAll
Constructor Detail

BabylonFileTransfer

public BabylonFileTransfer(java.lang.String fn,
                           long ts,
                           int tb,
                           int bs,
                           int minutes)
Method Detail

run

public abstract void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

getFileBlock

protected byte[] getFileBlock(int blockNumber)
                       throws java.lang.IndexOutOfBoundsException,
                              java.io.IOException
Read the requested block number from the file and return the data.

Throws:
java.lang.IndexOutOfBoundsException
java.io.IOException

putFileBlock

protected void putFileBlock(int blockNumber,
                            byte[] data)
                     throws java.lang.IndexOutOfBoundsException,
                            java.io.IOException
Write the requested block number to the file using the supplied data.

Throws:
java.lang.IndexOutOfBoundsException
java.io.IOException

Babylon Java Chat