ezvcard.io.text
Class VCardRawReader

java.lang.Object
  extended by ezvcard.io.text.VCardRawReader
All Implemented Interfaces:
Closeable

public class VCardRawReader
extends Object
implements Closeable

Parses a vCard data stream.

Author:
Michael Angstadt

Nested Class Summary
static class VCardRawReader.StopReadingException
          Instructs a VCardRawReader to stop reading from the data stream when thrown from a VCardRawReader.VCardDataStreamListener implementation.
static interface VCardRawReader.VCardDataStreamListener
          Handles the vCard data as it is read off the data stream.
 
Constructor Summary
VCardRawReader(Reader reader)
          Creates a new reader.
 
Method Summary
 void close()
          Closes the underlying Reader object.
 boolean eof()
          Determines whether the end of the data stream has been reached.
 Charset getEncoding()
          Gets the character encoding of the reader.
 int getLineNum()
          Gets the line number of the last line that was read.
 boolean isCaretDecodingEnabled()
           Gets whether the reader will decode parameter values that use circumflex accent encoding (enabled by default).
 void setCaretDecodingEnabled(boolean enable)
           Sets whether the reader will decode parameter values that use circumflex accent encoding (enabled by default).
 void start(VCardRawReader.VCardDataStreamListener listener)
          Starts or continues reading from the vCard data stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VCardRawReader

public VCardRawReader(Reader reader)
Creates a new reader.

Parameters:
reader - the reader to the data stream
Method Detail

getLineNum

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

Returns:
the line number

start

public void start(VCardRawReader.VCardDataStreamListener listener)
           throws IOException
Starts or continues reading from the vCard data stream.

Parameters:
listener - handles the vCard data as it is read off the wire
Throws:
IOException - if there is an I/O problem

isCaretDecodingEnabled

public boolean isCaretDecodingEnabled()

Gets whether the reader will decode parameter values that use circumflex accent encoding (enabled by default). This escaping mechanism allows newlines and double quotes to be included in parameter values.

Raw Character Encoded Character
" ^'
newline ^n
^ ^^

Example:

 GEO;X-ADDRESS="Pittsburgh Pirates^n115 Federal St^nPitt
  sburgh, PA 15212":40.446816;80.00566
 

Returns:
true if circumflex accent decoding is enabled, false if not
See Also:
RFC 6868

setCaretDecodingEnabled

public void setCaretDecodingEnabled(boolean enable)

Sets whether the reader will decode parameter values that use circumflex accent encoding (enabled by default). This escaping mechanism allows newlines and double quotes to be included in parameter values.

Raw Character Encoded Character
" ^'
newline ^n
^ ^^

Example:

 GEO;X-ADDRESS="Pittsburgh Pirates^n115 Federal St^nPitt
  sburgh, PA 15212":geo:40.446816,-80.00566
 

Parameters:
enable - true to use circumflex accent decoding, false not to
See Also:
RFC 6868

eof

public boolean eof()
Determines whether the end of the data stream has been reached.

Returns:
true if the end has been reached, false if not

getEncoding

public Charset getEncoding()
Gets the character encoding of the reader.

Returns:
the character encoding or null if none is defined

close

public void close()
           throws IOException
Closes the underlying Reader object.

Specified by:
close in interface Closeable
Throws:
IOException


Copyright © 2012-2014 Michael Angstadt. All Rights Reserved.