Top Description Fields Constructors Methods
net.fortuna.ical4j.data

public Class UnfoldingReader

extends PushbackReader
Class Inheritance
Imports
net.fortuna.ical4j.util.CompatibilityHints, org.slf4j.Logger, .LoggerFactory, java.io.IOException, .PushbackReader, .Reader, java.util.Arrays

$Id$ [06-Apr-2004]

A reader which performs iCalendar unfolding as it reads. Note that unfolding rules may be "relaxed" to allow unfolding of non-conformant *.ics files. By specifying the system property "ical4j.unfolding.relaxed=true" iCalendar files created with Mozilla Calendar/Sunbird may be correctly unfolded.

To wrap this reader with a java.io.BufferedReader you must ensure you specify an identical buffer size to that used in the java.io.BufferedReader.

Author
Ben Fortuna

Field Summary

Modifier and TypeField and Description
private final char[][]
private static final char[]
DEFAULT_FOLD_PATTERN_1

The pattern used to identify a fold in an iCalendar data stream.

private static final char[]
DEFAULT_FOLD_PATTERN_2

The pattern used to identify a fold in Microsoft Outlook 2007.

private int
private final Logger
private int
private final char[][]
private static final char[]
RELAXED_FOLD_PATTERN_1

The pattern used to identify a fold in Mozilla Calendar/Sunbird and KOrganizer.

private static final char[]
RELAXED_FOLD_PATTERN_2

The pattern used to identify a fold in Microsoft Outlook 2007.

Constructor Summary

AccessConstructor and Description
public
UnfoldingReader(final Reader
the reader to unfold from
in
)

Creates a new unfolding reader instance.

public
UnfoldingReader(final Reader
reader source for data
in
,
int
the buffer size
size
)

public
UnfoldingReader(final Reader
reader source for data
in
,
boolean
indicates whether relaxed unfolding is enabled
relaxed
)

public
UnfoldingReader(final Reader
a reader to read from
in
,
int
the buffer size
size
,
final boolean
specifies whether unfolding is relaxed
relaxed
)

Creates a new unfolding reader instance.

Method Summary

Modifier and TypeMethod and Description
public final int

Returns:

number of lines unfolded so far while reading
getLinesUnfolded
()

public final int
read()

Overrides java.io.PushbackReader.read.

Reads a single character.

public int
read(final char[]
Destination buffer
cbuf
,
final int
Offset at which to start storing characters
off
,
final int
Maximum number of characters to read
len
)

Overrides java.io.PushbackReader.read.

Reads characters into a portion of an array.

private void
Inherited from java.io.PushbackReader:
closemarkmarkSupportedreadyresetskipunreadunreadunread

Field Detail

buffersback to summary
private final char[][] buffers
DEFAULT_FOLD_PATTERN_1back to summary
private static final char[] DEFAULT_FOLD_PATTERN_1

The pattern used to identify a fold in an iCalendar data stream.

DEFAULT_FOLD_PATTERN_2back to summary
private static final char[] DEFAULT_FOLD_PATTERN_2

The pattern used to identify a fold in Microsoft Outlook 2007.

linesUnfoldedback to summary
private int linesUnfolded
logback to summary
private final Logger log
maxPatternLengthback to summary
private int maxPatternLength
patternsback to summary
private final char[][] patterns
RELAXED_FOLD_PATTERN_1back to summary
private static final char[] RELAXED_FOLD_PATTERN_1

The pattern used to identify a fold in Mozilla Calendar/Sunbird and KOrganizer.

RELAXED_FOLD_PATTERN_2back to summary
private static final char[] RELAXED_FOLD_PATTERN_2

The pattern used to identify a fold in Microsoft Outlook 2007.

Constructor Detail

UnfoldingReaderback to summary
public UnfoldingReader(final Reader in)

Creates a new unfolding reader instance. Relaxed unfolding flag is read from system property.

Parameters
in:Reader

the reader to unfold from

UnfoldingReaderback to summary
public UnfoldingReader(final Reader in, int size)
Parameters
in:Reader

reader source for data

size:int

the buffer size

UnfoldingReaderback to summary
public UnfoldingReader(final Reader in, boolean relaxed)
Parameters
in:Reader

reader source for data

relaxed:boolean

indicates whether relaxed unfolding is enabled

UnfoldingReaderback to summary
public UnfoldingReader(final Reader in, int size, final boolean relaxed)

Creates a new unfolding reader instance.

Parameters
in:Reader

a reader to read from

size:int

the buffer size

relaxed:boolean

specifies whether unfolding is relaxed

Method Detail

getLinesUnfoldedback to summary
public final int getLinesUnfolded()
Returns:int

number of lines unfolded so far while reading

readback to summary
public final int read() throws IOException

Overrides java.io.PushbackReader.read.

Doc from java.io.PushbackReader.read.

Reads a single character.

Returns:int

The character read, or -1 if the end of the stream has been reached

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
readback to summary
public int read(final char[] cbuf, final int off, final int len) throws IOException

Overrides java.io.PushbackReader.read.

Doc from java.io.PushbackReader.read.

Reads characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

If len is zero, then no characters are read and 0 is returned; otherwise, there is an attempt to read at least one character. If no character is available because the stream is at its end, the value -1 is returned; otherwise, at least one character is read and stored into cbuf.

Parameters
cbuf:char[]

Doc from java.io.Reader.read.

Destination buffer

off:int

Doc from java.io.Reader.read.

Offset at which to start storing characters

len:int

Doc from java.io.Reader.read.

Maximum number of characters to read

Returns:int

Doc from java.io.Reader.read.

The number of characters read, or -1 if the end of the stream has been reached

Annotations
@Override
Exceptions
IOException:

Doc from java.io.Reader.read.

If an I/O error occurs

unfoldback to summary
private void unfold() throws IOException