edu.rice.cs.cunit.util
Class PositionInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by edu.rice.cs.cunit.util.PositionInputStream
All Implemented Interfaces:
ProvidesInputStreamPosition, java.io.Closeable

public class PositionInputStream
extends java.io.FilterInputStream
implements ProvidesInputStreamPosition

A stream that makes the position in the stream available.


Field Summary
private  long mark
          Mark.
private  long pos
          Position.
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
PositionInputStream(java.io.InputStream in)
          Create a new PositionInputStream based on the stream given.
 
Method Summary
 long getPosition()
          Get the stream position.
 void mark(int readlimit)
           
 int read()
           
 int read(byte[] b, int off, int len)
           
 void reset()
           
 long skip(long skip)
           
 
Methods inherited from class java.io.FilterInputStream
available, close, markSupported, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pos

private long pos
Position.


mark

private long mark
Mark.

Constructor Detail

PositionInputStream

public PositionInputStream(java.io.InputStream in)
Create a new PositionInputStream based on the stream given.

Parameters:
in - input stream
Method Detail

getPosition

public long getPosition()

Get the stream position.

Eventually, the position will roll over to a negative number. Reading 1 Tb per second, this would occur after approximately three months. Applications should account for this possibility in their design.

Specified by:
getPosition in interface ProvidesInputStreamPosition
Returns:
the current stream position.

read

public int read()
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

skip

public long skip(long skip)
          throws java.io.IOException
Overrides:
skip in class java.io.FilterInputStream
Throws:
java.io.IOException

mark

public void mark(int readlimit)
Overrides:
mark in class java.io.FilterInputStream

reset

public void reset()
           throws java.io.IOException
Overrides:
reset in class java.io.FilterInputStream
Throws:
java.io.IOException