it.haefelinger.flaka.util
Class TextReader

java.lang.Object
  extended by it.haefelinger.flaka.util.TextReader

public class TextReader
extends Object

Author:
geronimo

Field Summary
protected  BufferedReader bufreader
           
protected  Pattern comment
           
protected  boolean continuation
           
protected  Project project
           
protected  boolean resolve
           
protected  String shift
           
protected  boolean skipempty
           
protected  boolean skipws
           
protected  String text
           
 
Constructor Summary
TextReader()
           
TextReader(String text)
           
 
Method Summary
 void addText(String text)
           
 String getShift()
           
 String getText()
           
protected  boolean ignore(String line)
          A method checking whether a input line shall be ignored or not.
static Pattern makepattern(String s)
          A small helper function generating a regular expression pattern.
 String read()
           
 String readLine()
           
static String resolvecontlines(String text)
          A helper function to resolve continuation lines.
 TextReader setComment(Pattern comment)
           
 TextReader setComment(String comment)
           
 TextReader setProject(Project project)
           
 TextReader setResolveContLines(boolean b)
           
 TextReader setShift(String s)
           
 TextReader setSkipEmpty(boolean b)
           
 TextReader setSkipws(boolean b)
           
 TextReader setText(String text)
           
static String stripws(String text)
          A helper method to strip unwanted whitespace from an input text.
static BufferedReader tobufreader(String text)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

comment

protected Pattern comment

skipempty

protected boolean skipempty

continuation

protected boolean continuation

text

protected String text

skipws

protected boolean skipws

shift

protected String shift

bufreader

protected BufferedReader bufreader

project

protected Project project

resolve

protected boolean resolve
Constructor Detail

TextReader

public TextReader(String text)

TextReader

public TextReader()
Method Detail

setProject

public TextReader setProject(Project project)

setText

public TextReader setText(String text)

addText

public void addText(String text)

setSkipws

public TextReader setSkipws(boolean b)

setShift

public TextReader setShift(String s)

getShift

public String getShift()

setComment

public TextReader setComment(String comment)

setComment

public TextReader setComment(Pattern comment)

setResolveContLines

public TextReader setResolveContLines(boolean b)

setSkipEmpty

public TextReader setSkipEmpty(boolean b)

getText

public String getText()

makepattern

public static Pattern makepattern(String s)
A small helper function generating a regular expression pattern. The pattern generated is meant to define the begin of a comment line. When using this pattern, use the Pattern.search() method instead of match. The pattern holds essentially the following regular expression
 ^\s*\Q{s}\E
 
where {s} denotes parameter s and where \Q means: treat upcoming chars literally until reaching \E. In other words, meta regular expression characters like * and the like are not honoured.

Parameters:
s - null allowed
Returns:
null if s is null, otherwise proper RE pattern.

ignore

protected boolean ignore(String line)
A method checking whether a input line shall be ignored or not. The given line is expected to hold any character but newline terminators. Such a line is typically given using the readLine() method of a Reader class. A line is ignored if
  1. being a comment line
  2. empty
However, checks wheather a comment line are only executed if a comment pattern has been installed. Empty lines are removed if attribute skipempty has been set to true.

Parameters:
line - not null
Returns:
true if line to be ignored

stripws

public static final String stripws(String text)
A helper method to strip unwanted whitespace from an input text. This method is expected to be called on a input text consiting of multiple lines.

Parameters:
text -
Returns:

resolvecontlines

public static final String resolvecontlines(String text)
A helper function to resolve continuation lines.

Parameters:
text -
Returns:

tobufreader

public static final BufferedReader tobufreader(String text)

readLine

public String readLine()
Returns:

read

public String read()