biz.c24.io.api.presentation.stream
Class DataReader

java.lang.Object
  extended by biz.c24.io.api.presentation.stream.DataReader
Direct Known Subclasses:
BorderedCharDataReader, ByteAlignedBitDataReader

public abstract class DataReader
extends Object

Data reader abstraction layer.

Provides the common API and general functional for an any incoming data reader.

Version:
$Revision: 128 $ $Date: 2007-10-29 22:51:58 +0000 (Mon, 29 Oct 2007) $

Nested Class Summary
 class DataReader.Locator
          The location representation class.
 
Constructor Summary
DataReader()
           
 
Method Summary
 int available()
          Returns the number of bytes that can be read from this input stream without blocking.
abstract  void close()
          Closes this reader and releases any system resources associated with it.
 boolean eof()
           
 InputStream getDataStream()
          Returns the underlied incoming data stream.
 DataReader.Locator getLocator()
          Current locator getter.
 int getLookAhead()
          Returns the look ahead limit.
 int getLookBehind()
          Returns the look behind limit.
 DataReader.Locator mark()
          Returns the snapshot of current location within data stream that can be used on rollback.
 void rollback(DataReader.Locator locator)
          Rollback on specified location.
 void setLookAhead(int lookAhead)
          Sets the look ahead limit.
 void setLookBehind(int lookBehind)
          Sets the look behind limit.
 int skip(int n)
          See the general contract of the skip method of InputStream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataReader

public DataReader()
Method Detail

getLookAhead

public final int getLookAhead()
Returns the look ahead limit.

Returns:
the look ahead limit (in bytes).

getLookBehind

public final int getLookBehind()
Returns the look behind limit.

Returns:
the look behind limit (in bytes).

setLookAhead

public final void setLookAhead(int lookAhead)
Sets the look ahead limit.

Parameters:
lookAhead - the new look ahead limit.

setLookBehind

public final void setLookBehind(int lookBehind)
Sets the look behind limit.

Parameters:
lookBehind - the new look behind limit.

getLocator

public final DataReader.Locator getLocator()
Current locator getter.

Provides client by locator instance. Returnad instance shouldn't be changed.

Returns:
the current locator instance.

skip

public int skip(int n)
         throws IOException
See the general contract of the skip method of InputStream.

Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.
Throws:
IOException - if an I/O error occurs.

mark

public final DataReader.Locator mark()
Returns the snapshot of current location within data stream that can be used on rollback.

Returns:
the current location snapshot.
See Also:
rollback(biz.c24.io.api.presentation.stream.DataReader.Locator)

rollback

public void rollback(DataReader.Locator locator)
Rollback on specified location.

Doing rollback to the specified locator position within incoming data stream. If that location stands beside the allowed limit the exception is throwned.

Parameters:
locator - the location of point within data stream to where location should be rolled back.
Throws:
IllegalStateException - If location is out from allowed range.
See Also:
mark()

available

public int available()
Returns the number of bytes that can be read from this input stream without blocking.

The available method of BufferedInputStream returns the sum of the the number of bytes remaining to be read in the buffer (count - pos) and the result of calling the available method of the underlying input stream.

Returns:
the number of bytes that can be read from this input stream without blocking.
See Also:
FilterInputStream.in

getDataStream

public InputStream getDataStream()
Returns the underlied incoming data stream.

The implementation may provide this. By default throws the exception.

Returns:
The incoming data stream.
Throws:
UnsupportedOperationException - If implementation doesn't provided that ability.

close

public abstract void close()
                    throws IOException
Closes this reader and releases any system resources associated with it.

Throws:
IOException - if an I/O error occurs.

eof

public final boolean eof()


Copyright © 2002-2007 IONA Technologies. All Rights Reserved.