org.codehaus.swizzle.stream
Class PushbackInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.codehaus.swizzle.stream.PushbackInputStream
All Implemented Interfaces:
java.io.Closeable, PushbackBuffer
Direct Known Subclasses:
TruncateInputStream

public class PushbackInputStream
extends java.io.InputStream
implements PushbackBuffer


Constructor Summary
PushbackInputStream()
           
PushbackInputStream(java.io.InputStream delegate)
           
 
Method Summary
protected  void addToMarkBuffer(byte b)
          Add a byte to the mark buffer if mark is active
 byte[] getBuffer()
          Gets the current contents of the buffer without modifying the position.
 java.io.InputStream getDelegate()
           
protected  int getNextByte()
           
 void mark(int readlimit)
          Activate mark/reset buffer.
 boolean markSupported()
           
 int read()
           
 void reset()
          Push the mark/reset buffer onto the pushback buffer, and release the mark
 void unmark()
          Release current mark/reset buffer.
 void unread(byte[] bytes)
          Push the bytes on to the head of the buffer, so they are the next bytes returned.
 void unread(byte[] bytes, int off, int len)
          Push the bytes on to the head of the buffer, so they are the next bytes returned.
 
Methods inherited from class java.io.InputStream
available, close, read, read, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PushbackInputStream

public PushbackInputStream()

PushbackInputStream

public PushbackInputStream(java.io.InputStream delegate)
Method Detail

getDelegate

public java.io.InputStream getDelegate()

read

public int read()
         throws java.io.IOException
Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException

getNextByte

protected int getNextByte()
                   throws java.io.IOException
Throws:
java.io.IOException

addToMarkBuffer

protected void addToMarkBuffer(byte b)
Add a byte to the mark buffer if mark is active


markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.InputStream

mark

public void mark(int readlimit)
Activate mark/reset buffer. This will release any previous marks.

Overrides:
mark in class java.io.InputStream
Parameters:
readlimit - suggested mark buffer size

unmark

public void unmark()
Release current mark/reset buffer.


reset

public void reset()
Push the mark/reset buffer onto the pushback buffer, and release the mark

Overrides:
reset in class java.io.InputStream

unread

public void unread(byte[] bytes)
Description copied from interface: PushbackBuffer
Push the bytes on to the head of the buffer, so they are the next bytes returned.

Specified by:
unread in interface PushbackBuffer

unread

public void unread(byte[] bytes,
                   int off,
                   int len)
Description copied from interface: PushbackBuffer
Push the bytes on to the head of the buffer, so they are the next bytes returned.

Specified by:
unread in interface PushbackBuffer

getBuffer

public byte[] getBuffer()
Description copied from interface: PushbackBuffer
Gets the current contents of the buffer without modifying the position.

Specified by:
getBuffer in interface PushbackBuffer


Copyright © 2011 The Codehaus Foundation. All Rights Reserved.