public class VCardSourceDetector extends Object implements VCardInterpreter
The class which tries to detects the source of a vCard file from its contents.
The specification of vCard (including both 2.1 and 3.0) is not so strict as to guess its format just by reading beginning few lines (usually we can, but in some most pessimistic case, we cannot until at almost the end of the file). Also we cannot store all vCard entries in memory, while there's no specification how big the vCard entry would become after the parse.
This class is usually used for the "first scan", in which we can understand which vCard version is used (and how many entries exist in a file).
Modifier and Type | Field and Description |
---|---|
static int |
PARSE_TYPE_UNKNOWN
Represents that no estimation is available.
|
Constructor and Description |
---|
VCardSourceDetector() |
Modifier and Type | Method and Description |
---|---|
String |
getEstimatedCharset()
Returns charset String guessed from the source's properties.
|
int |
getEstimatedType() |
void |
onEntryEnded()
Called when parsing one vCard entry ended.
|
void |
onEntryStarted()
Called when parsing one vCard entry started.
|
void |
onPropertyCreated(VCardProperty property)
Called when a property is created.
|
void |
onVCardEnded()
Called when vCard interpretation finished.
|
void |
onVCardStarted()
Called when vCard interpretation started.
|
public static final int PARSE_TYPE_UNKNOWN
public void onVCardStarted()
VCardInterpreter
onVCardStarted
in interface VCardInterpreter
public void onVCardEnded()
VCardInterpreter
onVCardEnded
in interface VCardInterpreter
public void onEntryStarted()
VCardInterpreter
VCardInterpreter.onEntryEnded()
is called, as vCard 2.1 accepts nested
vCard.
BEGIN:VCARD
BEGIN:VCARD
VERSION:2.1
N:test;;;;
END:VCARD
END:VCARD
onEntryStarted
in interface VCardInterpreter
public void onEntryEnded()
VCardInterpreter
onEntryEnded
in interface VCardInterpreter
public void onPropertyCreated(VCardProperty property)
VCardInterpreter
onPropertyCreated
in interface VCardInterpreter
public int getEstimatedType()
getEstimatedCharset()
to understand the charset to be used.public String getEstimatedCharset()
Returns charset String guessed from the source's properties. This method must be called after parsing target file(s).