ezvcard.io.html
Class HCardReader

java.lang.Object
  extended by ezvcard.io.html.HCardReader

public class HCardReader
extends Object

Parses VCard objects from an HTML page (hCard format).

Example:

 URL url = new URL("http://example.com");
 HCardReader hcardReader = new HCardReader(url);
 VCard vcard;
 while ((vcard = hcardReader.readNext()) != null){
   ...
 }
 

Author:
Michael Angstadt
See Also:
http://microformats.org/wiki/hcard

Constructor Summary
HCardReader(File file)
          Creates a reader that parses hCards from a file.
HCardReader(File file, String pageUrl)
          Creates a reader that parses hCards from a file.
HCardReader(InputStream in)
          Creates a reader that parses hCards from an input stream.
HCardReader(InputStream in, String pageUrl)
          Creates a reader that parses hCards from an input stream.
HCardReader(Reader reader)
          Creates a reader that parses hCards from a reader.
HCardReader(Reader reader, String pageUrl)
          Creates a reader that parses hCards from a reader.
HCardReader(String html)
          Creates a reader that parses hCards from a string.
HCardReader(String html, String pageUrl)
          Creates a reader that parses hCards from a string.
HCardReader(URL url)
          Creates a reader that parses hCards from a URL.
 
Method Summary
 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

HCardReader

public HCardReader(URL url)
            throws IOException
Creates a reader that parses hCards from a URL.

Parameters:
url - the URL of the webpage
Throws:
IOException - if there's a problem loading the webpage

HCardReader

public HCardReader(InputStream in)
            throws IOException
Creates a reader that parses hCards from an input stream.

Parameters:
in - the input stream to the HTML page
Throws:
IOException - if there's a problem reading the HTML page

HCardReader

public HCardReader(InputStream in,
                   String pageUrl)
            throws IOException
Creates a reader that parses hCards from an input stream.

Parameters:
in - the input stream to the HTML page
pageUrl - the original URL of the HTML page
Throws:
IOException - if there's a problem reading the HTML page

HCardReader

public HCardReader(File file)
            throws IOException
Creates a reader that parses hCards from a file.

Parameters:
file - the HTML file
Throws:
IOException - if there's a problem reading the HTML file

HCardReader

public HCardReader(File file,
                   String pageUrl)
            throws IOException
Creates a reader that parses hCards from a file.

Parameters:
file - the HTML file
pageUrl - the original URL of the HTML page
Throws:
IOException - if there's a problem reading the HTML file

HCardReader

public HCardReader(Reader reader)
            throws IOException
Creates a reader that parses hCards from a reader.

Parameters:
reader - the input stream to the HTML page
Throws:
IOException - if there's a problem reading the HTML page

HCardReader

public HCardReader(Reader reader,
                   String pageUrl)
            throws IOException
Creates a reader that parses hCards from a reader.

Parameters:
reader - the input stream to the HTML page
pageUrl - the original URL of the HTML page
Throws:
IOException - if there's a problem reading the HTML page

HCardReader

public HCardReader(String html)
Creates a reader that parses hCards from a string.

Parameters:
html - the HTML page

HCardReader

public HCardReader(String html,
                   String pageUrl)
Creates a reader that parses hCards from a string.

Parameters:
html - the HTML page
pageUrl - the original URL of the HTML page
Method Detail

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

readNext

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

Returns:
the next vCard or null if there are no more


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