net.sourceforge.pmd.lang.cpp
Class ContinuationReader

java.lang.Object
  extended by java.io.Reader
      extended by net.sourceforge.pmd.lang.cpp.ContinuationReader
All Implemented Interfaces:
Closeable, Readable

public class ContinuationReader
extends Reader

A custom Reader which completely omits C/C++ continuation character sequences from an underlying reader. Specifically the sequences \ \n (backslash, carriage return), or \ \r \n (backslash, line feed, carriage return).

This reader exists because to modify a JavaCC lexer to understand arbitrary continuations inside of any token is cumbersome, and just removing them from the input entirely is easier to implement. See this discussion on the JavaCC mailing list on line continuation character.


Field Summary
protected  PushbackReader in
          the original stream is wrapped in this pushback reader.
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
ContinuationReader(Reader in)
          Creates a new ContinuationReader which filters the given reader.
 
Method Summary
 void close()
           
 int read(char[] cbuf, int off, int len)
           
 
Methods inherited from class java.io.Reader
mark, markSupported, read, 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

in

protected final PushbackReader in
the original stream is wrapped in this pushback reader.

Constructor Detail

ContinuationReader

public ContinuationReader(Reader in)
Creates a new ContinuationReader which filters the given reader.

Parameters:
in - the given reader
Method Detail

read

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

close

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


Copyright © 2002-2016 InfoEther. All Rights Reserved.