biweekly.io.text
Class FoldedLineReader

java.lang.Object
  extended by java.io.Reader
      extended by java.io.BufferedReader
          extended by biweekly.io.text.FoldedLineReader
All Implemented Interfaces:
Closeable, Readable

public class FoldedLineReader
extends BufferedReader

Automatically unfolds lines of text as they are read.

Author:
Michael Angstadt

Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
FoldedLineReader(Reader reader)
          Creates a new folded line reader.
FoldedLineReader(String text)
          Creates a new folded line reader.
 
Method Summary
 int getLineNum()
          Gets the starting line number of the last unfolded line that was read.
 boolean isSingleSpaceFoldingEnabled()
          Gets whether the reader will only ignore the first whitespace character it encounters at the beginning of a folded line.
 String readLine()
          Reads the next line, unfolding it if necessary.
 void setSingleSpaceFoldingEnabled(boolean enabled)
          Sets whether the reader will only ignore the first whitespace character it encounters at the beginning of a folded line.
 
Methods inherited from class java.io.BufferedReader
close, mark, markSupported, read, read, ready, reset, skip
 
Methods inherited from class java.io.Reader
read, read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FoldedLineReader

public FoldedLineReader(Reader reader)
Creates a new folded line reader.

Parameters:
reader - the reader object to wrap

FoldedLineReader

public FoldedLineReader(String text)
Creates a new folded line reader.

Parameters:
text - the text to read
Method Detail

setSingleSpaceFoldingEnabled

public void setSingleSpaceFoldingEnabled(boolean enabled)
Sets whether the reader will only ignore the first whitespace character it encounters at the beginning of a folded line. This setting is enabled by default in order to support iCalendar files generated by Outlook.

Parameters:
enabled - true to enable (default), false to disable

isSingleSpaceFoldingEnabled

public boolean isSingleSpaceFoldingEnabled()
Gets whether the reader will only ignore the first whitespace character it encounters at the beginning of a folded line. This setting is enabled by default in order to support iCalendar files generated by Outlook.

Returns:
true if enabled (default), false if disabled

getLineNum

public int getLineNum()
Gets the starting line number of the last unfolded line that was read.

Returns:
the line number

readLine

public String readLine()
                throws IOException
Reads the next line, unfolding it if necessary.

Overrides:
readLine in class BufferedReader
Returns:
the next line or null if EOF
Throws:
IOException - if there's a problem reading from the reader


Copyright © 2013 Michael Angstadt. All Rights Reserved.