appli.diff
Class ASStreamIterator

java.lang.Object
  extended byappli.diff.ASStreamIterator
All Implemented Interfaces:
ASSourceIterator

class ASStreamIterator
extends java.lang.Object
implements ASSourceIterator

Local class reading the input file and returning the lines. Suppress all empty lines if NO_EMPTY_LINES is true. The line counter returns BEFORE a nextLine() is returned its line number. If empty lines are not returned, the counter returns the number of the next non empty line.

Version:
2.0 MW: add the option -e = suppress-empty-lines
Author:
Tal Davidson, Marc Wenger/CDS

Field Summary
(package private)  int currCount
           
(package private)  java.lang.String currLine
           
(package private)  boolean hasmorelines
           
(package private)  int lineCounter
           
(package private)  int lineNumber
           
(package private)  boolean NO_EMPTY_LINES
           
(package private)  java.io.BufferedReader rdr
           
 
Constructor Summary
ASStreamIterator(java.io.File f)
          Create an input stream from a File object
ASStreamIterator(java.io.InputStream in)
          Create an input stream interator from an input stream
ASStreamIterator(java.lang.String str)
          Create an input stream from a string
 
Method Summary
 int getLineCount()
          Get line counter
 boolean hasMoreLines()
          returns true if the stream has still lines to read
private  void init()
          Ini
 java.lang.String nextLine()
          returns the next line from the file
private  void readNextLine()
          read the next line.Prepares the variables for nextLine() and hasMoreLines()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_EMPTY_LINES

boolean NO_EMPTY_LINES

rdr

java.io.BufferedReader rdr

currLine

java.lang.String currLine

currCount

int currCount

lineCounter

int lineCounter

lineNumber

int lineNumber

hasmorelines

boolean hasmorelines
Constructor Detail

ASStreamIterator

public ASStreamIterator(java.io.InputStream in)
                 throws java.io.IOException
Create an input stream interator from an input stream

Parameters:
in - InputStream file
Throws:
java.io.IOException - if IO errors

ASStreamIterator

public ASStreamIterator(java.io.File f)
                 throws java.io.IOException
Create an input stream from a File object

Parameters:
f - File object
Throws:
java.io.IOException - if IO errors

ASStreamIterator

public ASStreamIterator(java.lang.String str)
                 throws java.io.IOException
Create an input stream from a string

Parameters:
str - a String containing a source file to beautify
Throws:
java.io.IOException - if IOError while initilizinf the BufferedReader
Method Detail

init

private void init()
           throws java.io.IOException
Ini

Throws:
java.io.IOException

hasMoreLines

public boolean hasMoreLines()
returns true if the stream has still lines to read

Specified by:
hasMoreLines in interface ASSourceIterator
Returns:
true if at least one line remains in the file

nextLine

public java.lang.String nextLine()
                          throws java.io.IOException
returns the next line from the file

Specified by:
nextLine in interface ASSourceIterator
Returns:
the next line without a final newline
Throws:
java.io.IOException - in case of IO error

readNextLine

private void readNextLine()
                   throws java.io.IOException
read the next line.Prepares the variables for nextLine() and hasMoreLines()

Throws:
java.io.IOException - in case of IO error

getLineCount

public int getLineCount()
Get line counter

Specified by:
getLineCount in interface ASSourceIterator
Returns:
the line counter current value