org.parancoe.yaml.parser
Class ParserReader

java.lang.Object
  extended by org.parancoe.yaml.parser.ParserReader

public final class ParserReader
extends java.lang.Object

A character Reader with some additional functionality.

This implementation uses a circular buffer with a default size of 64k. To create a ParserReader from a Reader do:

ParserReader parserReader = ParserReader(reader);

The constructor accepts any reader and returns a new reader with the functions defined here. As of now, this class is not an extension of Reader.

Care has to be taken when using mark(), unmark() and reset(), since they can be nested. Each mark() call has to be matched by exactly one unmark() or reset(). This code is now legal:

 ParserReader r = new ParserReader(reader);
 
 mark(); // position 1
 mark(); // position 2
 reset(); // return to position 2
 if (condition)
     reset(); // return to position 1
 else
     unmark();
 
 


Constructor Summary
ParserReader(java.io.Reader reader)
           
 
Method Summary
 int current()
          return one character from the stream without 'consuming' it
 void mark()
          remember the current position for a future reset()
 int previous()
          return the previous character
 int read()
          read and return one character from the stream.
 void reset()
          return to the position of a previous mark().
 java.lang.String string()
          return a string begining at the last mark() untill the current position
 void unmark()
           
 void unread()
          unread one character.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParserReader

public ParserReader(java.io.Reader reader)
             throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

string

public java.lang.String string()
return a string begining at the last mark() untill the current position


read

public int read()
         throws java.io.IOException
read and return one character from the stream.

Throws:
java.io.IOException

current

public int current()
            throws java.io.IOException
return one character from the stream without 'consuming' it

Throws:
java.io.IOException

previous

public int previous()
return the previous character


mark

public void mark()
remember the current position for a future reset()


unmark

public void unmark()

reset

public void reset()
return to the position of a previous mark().


unread

public void unread()
unread one character.



Copyright © 2007 JUG Padova Parancoe Team. All Rights Reserved.