|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectewe.util.Errorable
ewe.io.BasicStreamObject
ewe.io.StreamObject
ewe.io.RandomStreamObject
Use this to implement a RandomAccessStream object. To do this you must override: setStreamLength(), getStreamLength(), seekPosition(), tellPosition() and the other methods specified in StreamObject.
| Field Summary |
| Fields inherited from class ewe.io.StreamObject |
napIterations, napTime, READWRITE_CLOSED, READWRITE_ERROR, READWRITE_WOULDBLOCK |
| Fields inherited from class ewe.io.BasicStreamObject |
closed |
| Fields inherited from class ewe.util.Errorable |
error |
| Constructor Summary | |
RandomStreamObject()
|
|
| Method Summary | |
int |
getFilePosition()
Get the file position. |
int |
getLength()
Gets the length of the open stream. |
long |
getStreamLength()
Gets the length of the open stream. |
long |
length()
Get the current length of the stream. |
int |
nonBlockingRead(long location,
byte[] dest,
int offset,
int length)
Non-blocking read at a particular location. |
int |
nonBlockingWrite(long location,
byte[] src,
int offset,
int length)
Non-blocking write at a particular location. |
boolean |
seek(int position)
Set the file position. |
void |
seek(long position)
Set the stream position. |
boolean |
seekPosition(long pos)
Tell the Stream to move to the specific position. |
void |
setLength(long length)
Set the length of the RandomAccessStream if possible. |
boolean |
setStreamLength(long length)
Set the length of the RandomAccessStream if possible. |
long |
tell()
Get the current stream position. |
long |
tellPosition()
Retrieve the file position. |
RandomStream |
toRandomStream()
|
| Methods inherited from class ewe.io.StreamObject |
close, closeStream, doRead, doWrite, flush, isOpen, nap, nap, nonBlockingRead, nonBlockingWrite, read, readAByte, readBytes, readBytes, write, writeAByte, writeBytes, writeBytes |
| Methods inherited from class ewe.io.BasicStreamObject |
getException, getName, read, read, throwIOException, toInputStream, toOutputStream, toStream, write, write |
| Methods inherited from class ewe.util.Errorable |
returnError, returnError, returnError |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, toString |
| Methods inherited from interface ewe.io.BasicRandomAccessStream |
canWrite |
| Methods inherited from interface ewe.io.BasicStream |
close, closeStream, flushStream, isOpen, nonBlockingRead, nonBlockingWrite |
| Methods inherited from interface ewe.io.Stream |
flush, read, read, read, readBytes, readBytes, toInputStream, toOutputStream, write, write, write, writeBytes, writeBytes |
| Constructor Detail |
public RandomStreamObject()
| Method Detail |
public boolean setStreamLength(long length)
throws IOException
BasicRandomAccessStreamMake no assumptions about the success of this method. Not all RAS objects will support setStreamLength() or setLength() - not even all Files on all systems will support this. For example, PersonalJava/Java 1.1 does not support this feature and will throw an IOException.
What happens to the file position pointer after this method is called is unpredictable, especially if you are truncating the file. You should ALWAYS reset the file position pointer after calling this method to be where you wish it to be.
setStreamLength in interface BasicRandomAccessStreamIOException
public void setLength(long length)
throws IOException
RandomAccessStreamMake no assumptions about the success of this method. Not all RAS objects will support setStreamLength() or setLength() - not even all Files on all systems will support this. For example, PersonalJava/Java 1.1 does not support this feature and will throw an IOException.
What happens to the file position pointer after this method is called is unpredictable, especially if you are truncating the file. You should ALWAYS reset the file position pointer after calling this method to be where you wish it to be.
setLength in interface RandomAccessStreamIOException
public long length()
throws IOException
RandomAccessStream
length in interface RandomAccessStreamIOException - if an error occurs.public int getLength()
RandomAccessStream
getLength in interface RandomAccessStream
public long tell()
throws IOException
RandomAccessStream
tell in interface RandomAccessStreamIOException - if an error occurs.public int getFilePosition()
RandomAccessStream
getFilePosition in interface RandomAccessStream
public void seek(long position)
throws IOException
RandomAccessStream
seek in interface RandomAccessStreamposition - The position to seek to.
IOException - if an error occurs while seeking.public boolean seek(int position)
RandomAccessStream
seek in interface RandomAccessStreamposition - The new file position to set.
public boolean seekPosition(long pos)
throws IOException
seekPosition in interface BasicRandomAccessStreampos - The position to seek to.
IOException - if an error occured during the seek.
public long tellPosition()
throws IOException
tellPosition in interface BasicRandomAccessStreamIOException - if an error occured while getting the position.
public long getStreamLength()
throws IOException
getStreamLength in interface BasicRandomAccessStreamIOException - if an error occured while getting the length.
public int nonBlockingRead(long location,
byte[] dest,
int offset,
int length)
throws IOException
BasicRandomAccessStream
nonBlockingRead in interface BasicRandomAccessStreamlocation - The location to read from.dest - The destination buffer.offset - The location in the buffer to hold the data.length - The number of bytes to read.
IOException - if an error occured during reading.
public int nonBlockingWrite(long location,
byte[] src,
int offset,
int length)
throws IOException
BasicRandomAccessStream
nonBlockingWrite in interface BasicRandomAccessStreamlocation - The location to write to.src - The source buffer.offset - The location in the buffer that holds the data.length - The number of bytes to write.
IOException - if an error occured during writing.public RandomStream toRandomStream()
toRandomStream in interface RandomAccessStream
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||