org.apache.tapestry.util.text
Class ExtendedReader

java.lang.Object
  extended by java.io.Reader
      extended by org.apache.tapestry.util.text.ExtendedReader
All Implemented Interfaces:
Closeable, Readable

public class ExtendedReader
extends Reader

A Reader that provides some additional functionality, such as peek().

Since:
4.0
Author:
mb

Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
ExtendedReader(Reader in)
          Creates a new extended reader that reads from the provided object.
 
Method Summary
 void close()
           
 boolean isEndOfStream()
          Determines whether the end of the stream is reached.
 boolean markSupported()
           
 int peek()
          Returns the next character in the stream without actually comitting the read.
 int read(char[] cbuf, int off, int len)
           
 String readCharacters(ICharacterMatcher matcher)
          Reads the next characters until a character that does not match the provided rule is reached.
 boolean ready()
           
 void reset()
           
 long skip(long n)
           
 void skipCharacters(ICharacterMatcher matcher)
          Skips the next characters until a character that does not match the provided rule is reached.
 
Methods inherited from class java.io.Reader
mark, read, read, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExtendedReader

public ExtendedReader(Reader in)
Creates a new extended reader that reads from the provided object.

Parameters:
in - the Reader to get data from
Method Detail

peek

public int peek()
         throws IOException
Returns the next character in the stream without actually comitting the read. Multiple consequtive invocations of this method should return the same value.

Returns:
the next character waiting in the stream or -1 if the end of the stream is reached
Throws:
IOException - if an error occurs

isEndOfStream

public boolean isEndOfStream()
                      throws IOException
Determines whether the end of the stream is reached.

Returns:
true if at the end of stream
Throws:
IOException - if an error occurs

skipCharacters

public void skipCharacters(ICharacterMatcher matcher)
                    throws IOException
Skips the next characters until a character that does not match the provided rule is reached.

Parameters:
matcher - the object determining whether a character should be skipped
Throws:
IOException - if an error occurs

readCharacters

public String readCharacters(ICharacterMatcher matcher)
                      throws IOException
Reads the next characters until a character that does not match the provided rule is reached.

Parameters:
matcher - the object determining whether a character should be read
Returns:
the string of characters read
Throws:
IOException - if an error occurs

read

public int read(char[] cbuf,
                int off,
                int len)
         throws IOException
Specified by:
read in class Reader
Throws:
IOException
See Also:
FilterReader.read(char[], int, int)

ready

public boolean ready()
              throws IOException
Overrides:
ready in class Reader
Throws:
IOException
See Also:
FilterReader.ready()

markSupported

public boolean markSupported()
Overrides:
markSupported in class Reader
See Also:
FilterReader.markSupported()

reset

public void reset()
           throws IOException
Overrides:
reset in class Reader
Throws:
IOException
See Also:
FilterReader.reset()

skip

public long skip(long n)
          throws IOException
Overrides:
skip in class Reader
Throws:
IOException
See Also:
FilterReader.skip(long)

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Specified by:
close in class Reader
Throws:
IOException
See Also:
Reader.close()


Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.