org.codehaus.groovy.antlr
Class UnicodeEscapingReader

java.lang.Object
  extended by java.io.Reader
      extended by org.codehaus.groovy.antlr.UnicodeEscapingReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public class UnicodeEscapingReader
extends java.io.Reader

Translates GLS-defined unicode escapes into characters. Throws an exception in the event of an invalid unicode escape being detected.

No attempt has been made to optimise this class for speed or space.

Version:
$Revision: 7922 $

Field Summary
private  boolean hasNextChar
           
private  antlr.CharScanner lexer
           
private  int nextChar
           
private  java.io.Reader reader
           
private  SourceBuffer sourceBuffer
           
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
UnicodeEscapingReader(java.io.Reader reader, SourceBuffer sourceBuffer)
          Constructor.
 
Method Summary
private  void checkHexDigit(int c)
          Checks that the given character is indeed a hex digit.
 void close()
          Closes this reader by calling close on the underlying reader.
 int read()
          Gets the next character from the underlying reader, translating escapes as required.
 int read(char[] cbuf, int off, int len)
          Reads characters from the underlying reader.
 void setLexer(antlr.CharScanner lexer)
          Sets the lexer that is using this reader.
private  void write(int c)
           
 
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

reader

private final java.io.Reader reader

lexer

private antlr.CharScanner lexer

hasNextChar

private boolean hasNextChar

nextChar

private int nextChar

sourceBuffer

private final SourceBuffer sourceBuffer
Constructor Detail

UnicodeEscapingReader

public UnicodeEscapingReader(java.io.Reader reader,
                             SourceBuffer sourceBuffer)
Constructor.

Parameters:
reader - The reader that this reader will filter over.
Method Detail

setLexer

public void setLexer(antlr.CharScanner lexer)
Sets the lexer that is using this reader. Must be called before the lexer is used.


read

public int read(char[] cbuf,
                int off,
                int len)
         throws java.io.IOException
Reads characters from the underlying reader.

Specified by:
read in class java.io.Reader
Throws:
java.io.IOException
See Also:
Reader.read(char[],int,int)

read

public int read()
         throws java.io.IOException
Gets the next character from the underlying reader, translating escapes as required.

Overrides:
read in class java.io.Reader
Throws:
java.io.IOException
See Also:
Reader.close()

write

private void write(int c)

checkHexDigit

private void checkHexDigit(int c)
                    throws java.io.IOException
Checks that the given character is indeed a hex digit.

Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Closes this reader by calling close on the underlying reader.

Specified by:
close in interface java.io.Closeable
Specified by:
close in class java.io.Reader
Throws:
java.io.IOException
See Also:
Reader.close()


Copyright © ${year} The Codehaus. All Rights Reserved.