things.data.impl
Class FileAccessor

java.lang.Object
  extended by things.data.impl.FileAccessor
All Implemented Interfaces:
Accessor

public class FileAccessor
extends java.lang.Object
implements Accessor

This is a cheap access for a file. Only one access allowed at a time!

You are at the mercy of the implementation in terms of multithreading.

Version:
1.0

Version History

EPG - Initial - 13 JAN 05
 
Author:
Erich P. Gatejen

Constructor Summary
FileAccessor(java.io.File theFile)
          Constructor.
 
Method Summary
 void doneWithRead(java.io.InputStream ios)
          Declare you are done reading from the input stream.
 void doneWithWrite(java.io.OutputStream oos)
          Declare you are done reading from the input stream.
 java.io.InputStream openForRead()
          Open the item for read.
 java.io.OutputStream openForWrite()
          Open the item for writing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileAccessor

public FileAccessor(java.io.File theFile)
             throws ThingsException
Constructor.

Throws:
ThingsException
Method Detail

openForRead

public java.io.InputStream openForRead()
                                throws ThingsException
Open the item for read. You can assume it is buffered.

Specified by:
openForRead in interface Accessor
Returns:
return an input stream for the item. It will never return null; problems will cause exceptions.
Throws:
ThingsException - for any problem.

doneWithRead

public void doneWithRead(java.io.InputStream ios)
                  throws ThingsException
Declare you are done reading from the input stream. It is a good idea to call this, though it shouldn't be fatal if you don't.

Specified by:
doneWithRead in interface Accessor
Parameters:
ios - the stream you were given when you openForRead(). You may close the stream already, if you want.
Throws:
ThingsException - for any problem.

openForWrite

public java.io.OutputStream openForWrite()
                                  throws ThingsException
Open the item for writing. You can assume it is buffered.

Specified by:
openForWrite in interface Accessor
Returns:
return an output stream for the item. It will never return null; problems will cause exceptions.
Throws:
ThingsException - for any problem.

doneWithWrite

public void doneWithWrite(java.io.OutputStream oos)
                   throws ThingsException
Declare you are done reading from the input stream. It is a good idea to call this, though it shouldn't be fatal if you don't.

Specified by:
doneWithWrite in interface Accessor
Parameters:
oos - the stream you were given when you openForWrite(). You may flush and close the stream already, if you want.
Throws:
ThingsException - for any problem.


Things.