au.com.prunge.jgenfile.impl
Class AbstractFileAccessor

java.lang.Object
  |
  +--au.com.prunge.jgenfile.impl.AbstractFileAccessor
All Implemented Interfaces:
FileAccessor
Direct Known Subclasses:
LocalFileAccessor

public abstract class AbstractFileAccessor
extends Object
implements FileAccessor

An abstract file accessor class to ease development of other file accessors.

Version:
1.0
Author:
Peter Runge

Constructor Summary
AbstractFileAccessor()
          Constructs an AbstractFileAccessor.
 
Method Summary
protected  void checkAcquired()
          If channelAcquired is true, throws an exception.
protected  void checkClosed()
          If accessorClosed is true, throws an exception.
protected  void checkGetChannel()
          Calls btoh checkAcquired() and checkClosed().
 boolean isAccessorClosed()
          Returns whether this file accessor has been closed.
 boolean isChannelAcquired()
          Returns whether a channel has been acquired from this accessor.
protected  void setAccessorClosed(boolean accessorClosed)
          Sets the accessorClosed variable.
protected  void setChannelAcquired(boolean channelAcquired)
          Sets the channelAcquired variable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface au.com.prunge.jgenfile.FileAccessor
createCloseOperation, getRandomAccessReadChannel, getRandomAccessReadWriteChannel, getRandomAccessWriteChannel, getReadChannel, getReadWriteChannel, getWriteChannel
 

Constructor Detail

AbstractFileAccessor

public AbstractFileAccessor()
Constructs an AbstractFileAccessor.

Method Detail

isChannelAcquired

public boolean isChannelAcquired()
Description copied from interface: FileAccessor
Returns whether a channel has been acquired from this accessor.

Specified by:
isChannelAcquired in interface FileAccessor
Returns:
true if a channel has been acquired, false if a channel is available.
See Also:
FileAccessor.isChannelAcquired()

isAccessorClosed

public boolean isAccessorClosed()
Description copied from interface: FileAccessor
Returns whether this file accessor has been closed.

Specified by:
isAccessorClosed in interface FileAccessor
Returns:
true if this file accessor is closed, false if not.
See Also:
FileAccessor.isAccessorClosed()

setAccessorClosed

protected void setAccessorClosed(boolean accessorClosed)
Sets the accessorClosed variable. If set to true, subsequent checkClosed() calls will throw a FileAccessorClosedException.

Parameters:
accessorClosed - true to throw an exception on the next checkClosed() call, false otherwise.

setChannelAcquired

protected void setChannelAcquired(boolean channelAcquired)
Sets the channelAcquired variable. If set to true, subsequent checkAcquired() calls will throw a ChannelAcquiredException.

Parameters:
channelAcquired - true to throw an exception on the next checkAcquried() call, false otherwise.

checkClosed

protected void checkClosed()
                    throws FileAccessorClosedException
If accessorClosed is true, throws an exception. Otherwise does nothing.

Throws:
FileAccessorClosedException - if accessorClosed is true.
See Also:
setAccessorClosed(boolean)

checkAcquired

protected void checkAcquired()
                      throws ChannelAcquiredException
If channelAcquired is true, throws an exception. Otherwise does nothing.

Throws:
ChannelAcquiredException - if channelAcquired is true.
See Also:
AbstractFileAccessor#setChannelAcquried

checkGetChannel

protected void checkGetChannel()
                        throws FileAccessorClosedException,
                               ChannelAcquiredException
Calls btoh checkAcquired() and checkClosed().

Subclasses may call this method to verify that a channel has not already been acquired and that the file accessor is not closed.

Throws:
FileAccessorClosedException - if accessorClosed is true.
ChannelAcquiredException - if channelAcquired is true.