com.taleo.integration.client.customstep.util.csv
Class PeekReader

java.lang.Object
  extended by java.io.Reader
      extended by com.taleo.integration.client.customstep.util.csv.PeekReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public class PeekReader
extends java.io.Reader

PeekReader is a reader that reads some data in advance from the underlying reader. It can be used when you want to know in advance what is coming in the source of character. You must specify the number of characters that must be read in advance to the constructor.

Since:
ITK 2.1
Author:
raudet

Field Summary
protected  int nbBuffered
          The current remaining number of character that are available from the pre-read buffer.
protected  int posEnd
          The current end position in the pre-read buffer
protected  int posStart
          The current start position in the pre-read buffer
protected  char[] preReadBuffer
          This is the buffer in which the pre-read characters will be stored
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
PeekReader(java.io.Reader pReader, int pPreReadSize)
          Constructs a PeekReader based on the specified reader and the specified number of characters that must be read in advance.
 
Method Summary
 boolean bufferEquals(java.lang.String pValue)
          Return true if the pre-read buffer content equals the specified String.
 boolean bufferIsEmpty()
          Return true if the pre-read buffer is empty.
 boolean bufferStartsWith(java.lang.String pValue)
          Returns true if the characters in the pre-read buffer starts with the specified string.
 void close()
          
protected  boolean isEnd()
          Returns the end.
protected  void preRead()
          Fill the pre-read buffer with the next available chars from the underlying reader.
 int read()
          
 int read(char[] pCbuf, int pOff, int pLen)
          
 
Methods inherited from class java.io.Reader
mark, markSupported, read, read, ready, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

preReadBuffer

protected char[] preReadBuffer
This is the buffer in which the pre-read characters will be stored


posStart

protected int posStart
The current start position in the pre-read buffer


posEnd

protected int posEnd
The current end position in the pre-read buffer


nbBuffered

protected int nbBuffered
The current remaining number of character that are available from the pre-read buffer.

Constructor Detail

PeekReader

public PeekReader(java.io.Reader pReader,
                  int pPreReadSize)
Constructs a PeekReader based on the specified reader and the specified number of characters that must be read in advance.

Parameters:
pReader - The underlying reader from which to read the characters
pPreReadSize - The size of the pre-read buffer
Method Detail

close

public void close()
           throws java.io.IOException

Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Reader
Throws:
java.io.IOException

read

public int read(char[] pCbuf,
                int pOff,
                int pLen)
         throws java.io.IOException

Specified by:
read in class java.io.Reader
Throws:
java.io.IOException

bufferStartsWith

public boolean bufferStartsWith(java.lang.String pValue)
Returns true if the characters in the pre-read buffer starts with the specified string.

Parameters:
pValue - The string that must match the start of the pre-read buffer
Returns:
true if the characters in the pre-read buffer starts with the specified string.

bufferEquals

public boolean bufferEquals(java.lang.String pValue)
Return true if the pre-read buffer content equals the specified String.

Parameters:
pValue - The string that must be equals to the pre-read buffer content
Returns:
true if the pre-read buffer content equals the specified String

bufferIsEmpty

public boolean bufferIsEmpty()
Return true if the pre-read buffer is empty.

Returns:
true if the pre-read buffer content is empty

read

public int read()
         throws java.io.IOException

Overrides:
read in class java.io.Reader
Throws:
java.io.IOException

preRead

protected void preRead()
Fill the pre-read buffer with the next available chars from the underlying reader.


isEnd

protected final boolean isEnd()
Returns the end.

Returns:
the end.