public class VCardParser_V40 extends VCardParser
vCard parser for vCard 4.0. DO NOT USE IN PRODUCTION.
Currently this parser is based on vCard 4.0 specification rev 15 (partly). Note that some of current implementation lack basic capability required in vCard 4.0. (e.g. PHOTO has data parameter in rev 15 while this implementation requires "ENCODING=b")
Constructor and Description |
---|
VCardParser_V40() |
VCardParser_V40(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_V40()
public VCardParser_V40(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