ghm.follow
Class FileFollower

java.lang.Object
ghm.follow.FileFollower

public class FileFollower

extends java.lang.Object

Instances of this class 'follow' a particular text file, assmebling that
file's characters into Strings and sending them to instances of
OutputDestination. The name and behavior of this class are inspired
by the '-f' (follow) flag of the UNIX command 'tail'.

FileFollower(java.io.File file,
int bufferSize,
int latency,
OutputDestination[] initialOutputDestinations)
Constructs a new FileFollower; invoking this constructor does
not cause the new object to begin following the supplied file.

getOutputDestinations

Returns the List which maintains all OutputDestinations for this
FileFollower.

Returns:

contains all OutputDestinations for this FileFollower

getFollowedFile

public java.io.File getFollowedFile()

Returns the file which is being followed by this FileFollower

Returns:

file being followed

isBeingFollowed

public boolean isBeingFollowed()

Returns the following state of a file

Returns:

true if being followed, false if not being followed

isPaused

public boolean isPaused()

Returns the pause state of the follower.

Returns:

true if paused, false otherwise

getBufferSize

public int getBufferSize()

Returns the size of the character buffer used to read characters from the
followed file. Each time the file is accessed, this buffer is filled.

Returns:

size of the character buffer

setBufferSize

public void setBufferSize(int bufferSize)

Sets the size of the character buffer used to read characters from the
followed file. Increasing buffer size will improve efficiency but
increase the amount of memory used by the FileFollower.NOTE: Setting this value will not cause a running
FileFollower to immediately begin reading characters into a buffer of the
newly specified size. You must stop & restart the FileFollower in order
for changes to take effect.

Parameters:

bufferSize - size of the character buffer

getLatency

public int getLatency()

Returns the time (in milliseconds) which a FileFollower spends sleeping
each time it encounters the end of the followed file.

Returns:

latency, in milliseconds

setLatency

public void setLatency(int latency)

Sets the time (in milliseconds) which a FileFollower spends sleeping each
time it encounters the end of the followed file. Note that extremely low
latency values may cause thrashing between the FileFollower's running
thread and other threads in an application. A change in this value will
be reflected the next time the FileFollower's running thread sleeps.