Project JXTA

net.jxta.util
Class MarkProhibitedFilterStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.FilterInputStream
              |
              +--net.jxta.util.MarkProhibitedFilterStream

public class MarkProhibitedFilterStream
extends java.io.FilterInputStream

Implements a filter which disables the mark() feature of an input stream. Useful for when the stream is shared.


Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
MarkProhibitedFilterStream(java.io.InputStream in)
          Creates a new instance of MarkProhibitedFilterStream
 
Method Summary
 void mark(int readlimit)
          Marks the current position in this input stream.
 boolean markSupported()
          Tests if this input stream supports the mark and reset methods.
 void reset()
          Repositions this stream to the position at the time the mark method was last called on this input stream.
 
Methods inherited from class java.io.FilterInputStream
available, close, read, read, read, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MarkProhibitedFilterStream

public MarkProhibitedFilterStream(java.io.InputStream in)
Creates a new instance of MarkProhibitedFilterStream
Parameters:
in - the stream which will be limited.
limit - the number of bytes which can be read from the stream.
Method Detail

mark

public void mark(int readlimit)
Marks the current position in this input stream. A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.

The readlimit argument tells this input stream to allow that many bytes to be read before the mark position gets invalidated.

This method does nothing.

Overrides:
mark in class java.io.FilterInputStream
Parameters:
readlimit - the maximum limit of bytes that can be read before the mark position becomes invalid.
See Also:
FilterInputStream.in, FilterInputStream.reset()

reset

public void reset()
           throws java.io.IOException
Repositions this stream to the position at the time the mark method was last called on this input stream.

This method simply performs in.reset().

Stream marks are intended to be used in situations where you need to read ahead a little to see what's in the stream. Often this is most easily done by invoking some general parser. If the stream is of the type handled by the parse, it just chugs along happily. If the stream is not of that type, the parser should toss an exception when it fails. If this happens within readlimit bytes, it allows the outer code to reset the stream and try another parser.

Overrides:
reset in class java.io.FilterInputStream
Throws:
java.io.IOException - if the stream has not been marked or if the mark has been invalidated.
See Also:
FilterInputStream.in, FilterInputStream.mark(int)

markSupported

public boolean markSupported()
Tests if this input stream supports the mark and reset methods.

This method simply returns false.

Overrides:
markSupported in class java.io.FilterInputStream
Returns:
false.
See Also:
FilterInputStream.in, InputStream.mark(int), InputStream.reset()

Project JXTA