public final class VCardParser_V21 extends VCardParser
The spec is written in 1996, and currently various types of "vCard 2.1" exist. To handle real the world vCard formats appropriately and effectively, this class does not obey with strict vCard 2.1. In stead, not only vCard spec but also real world vCard is considered.
e.g. A lot of devices and softwares let vCard importer/exporter to use the PNG format to determine the type of image, while it is not allowed in the original specification. As of 2010, we can see even the FLV format (possible in Japanese mobile phones).Constructor and Description |
---|
VCardParser_V21() |
VCardParser_V21(int vcardType) |
Modifier and Type | Method and Description |
---|---|
void |
addInterpreter(VCardInterpreter interpreter)
Registers one
VCardInterpreter instance, which receives events along with
vCard parsing. |
void |
cancel()
Cancel parsing vCard.
|
void |
parse(InputStream is)
Parses a whole InputStream as a vCard file and lets registered
VCardInterpreter
instances handle callbacks. |
void |
parseOne(InputStream is)
Parses the first vCard entry in InputStream and lets registered
VCardInterpreter
instances handle callbacks. |
parse
public VCardParser_V21()
public VCardParser_V21(int vcardType)
public void addInterpreter(VCardInterpreter interpreter)
VCardParser
VCardInterpreter
instance, which receives events along with
vCard parsing.addInterpreter
in class VCardParser
public void parse(InputStream is) throws IOException, VCardException
VCardParser
Parses a whole InputStream as a vCard file and lets registered VCardInterpreter
instances handle callbacks.
This method reads a whole InputStream. If you just want to parse one vCard entry inside
a vCard file with multiple entries, try VCardParser.parseOne(InputStream)
.
parse
in class VCardParser
is
- The source to parse.IOException
VCardException
public void parseOne(InputStream is) throws IOException, VCardException
VCardParser
Parses the first vCard entry in InputStream and lets registered VCardInterpreter
instances handle callbacks.
This method finishes itself when the first entry ended.
Note that, registered VCardInterpreter
may still see multiple
VCardInterpreter.onEntryStarted()
/ VCardInterpreter.onEntryEnded()
calls
even with this method.
This happens when the first entry contains nested vCards, which is allowed in vCard 2.1. See the following example.
BEGIN:VCARD
N:a
BEGIN:VCARD
N:b
END:VCARD
END:VCARD
With this vCard, registered interpreters will grab two
VCardInterpreter.onEntryStarted()
and VCardInterpreter.onEntryEnded()
calls. Callers should handle the situation by themselves.
parseOne
in class VCardParser
is
- The source to parse.IOException
VCardException
public void cancel()
VCardParser
Cancel parsing vCard. Useful when you want to stop the parse in the other threads.
Actual cancel is done after parsing the current vcard.
cancel
in class VCardParser