things.data.impl
Class StringAccessor

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

public class StringAccessor
extends java.lang.Object
implements Accessor

This is a cheap access for a string. You can read it all you want. Writing dumps stuff in a ByteArrayOutputStream. You can ask for it before you are doneWithWrite.

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

Version:
1.0

Version History

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

Constructor Summary
StringAccessor(java.lang.String theString)
          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.ByteArrayOutputStream getOutputStream()
          Get the output 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

StringAccessor

public StringAccessor(java.lang.String theString)
               throws ThingsException
Constructor.

Throws:
ThingsException
Method Detail

getOutputStream

public java.io.ByteArrayOutputStream getOutputStream()
Get the output stream. It'll be null if it isn't open for write.

Returns:
the output stream.

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.