it.haefelinger.flaka.util
Class TextReader
java.lang.Object
it.haefelinger.flaka.util.TextReader
public class TextReader
- extends Object
- Author:
- geronimo
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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
TextReader
public TextReader(String text)
TextReader
public TextReader()
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
- being a comment line
- 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()