ezvcard.io.json
Class JCardReader

java.lang.Object
  extended by ezvcard.io.json.JCardReader
All Implemented Interfaces:
Closeable

public class JCardReader
extends Object
implements Closeable

Parses VCard objects from a JSON data stream (jCard format).

Example:

 File file = new File("vcards.json");
 JCardReader jcardReader = new JCardReader(file);
 VCard vcard;
 while ((vcard = jcardReader.readNext()) != null){
   ...
 }
 jcardReader.close();
 

Author:
Michael Angstadt
See Also:
jCard draft

Constructor Summary
JCardReader(File file)
          Creates a reader that parses jCards from a file.
JCardReader(InputStream in)
          Creates a reader that parses jCards from an input stream.
JCardReader(Reader reader)
          Creates a reader that parses jCards from a reader.
JCardReader(String json)
          Creates a reader that parses jCards from a JSON string.
 
Method Summary
 void close()
           
 ScribeIndex getScribeIndex()
          Gets the scribe index.
 List<String> getWarnings()
          Gets the warnings from the last vCard that was unmarshalled.
 VCard readNext()
          Reads the next vCard from the data stream.
 void registerScribe(VCardPropertyScribe<? extends VCardProperty> scribe)
           Registers a property scribe.
 void setScribeIndex(ScribeIndex index)
          Sets the scribe index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JCardReader

public JCardReader(String json)
Creates a reader that parses jCards from a JSON string.

Parameters:
json - the JSON string

JCardReader

public JCardReader(InputStream in)
Creates a reader that parses jCards from an input stream.

Parameters:
in - the input stream to read the vCards from

JCardReader

public JCardReader(File file)
            throws FileNotFoundException
Creates a reader that parses jCards from a file.

Parameters:
file - the file to read the vCards from
Throws:
FileNotFoundException - if the file doesn't exist

JCardReader

public JCardReader(Reader reader)
Creates a reader that parses jCards from a reader.

Parameters:
reader - the reader to read the vCards from
Method Detail

readNext

public VCard readNext()
               throws IOException
Reads the next vCard from the data stream.

Returns:
the next vCard or null if there are no more
Throws:
IOException - if there's a problem reading from the stream

registerScribe

public void registerScribe(VCardPropertyScribe<? extends VCardProperty> scribe)

Registers a property scribe. This is the same as calling:

getScribeIndex().register(scribe)

Parameters:
scribe - the scribe to register

getScribeIndex

public ScribeIndex getScribeIndex()
Gets the scribe index.

Returns:
the scribe index

setScribeIndex

public void setScribeIndex(ScribeIndex index)
Sets the scribe index.

Parameters:
index - the scribe index

getWarnings

public List<String> getWarnings()
Gets the warnings from the last vCard that was unmarshalled. This list is reset every time a new vCard is read.

Returns:
the warnings or empty list if there were no warnings

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Throws:
IOException


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