use of ezvcard.io.CannotParseException in project ez-vcard by mangstadt.
the class ClientPidMapScribe method _parseText.
@Override
protected ClientPidMap _parseText(String value, VCardDataType dataType, VCardParameters parameters, ParseContext context) {
SemiStructuredValueIterator it = new SemiStructuredValueIterator(value, 2);
String pid = it.next();
String uri = it.next();
if (pid == null || uri == null) {
throw new CannotParseException(3);
}
return parse(pid, uri);
}
use of ezvcard.io.CannotParseException in project ez-vcard by mangstadt.
the class GeoScribe method _parseText.
@Override
protected Geo _parseText(String value, VCardDataType dataType, VCardParameters parameters, ParseContext context) {
if (value.length() == 0) {
return new Geo((GeoUri) null);
}
switch(context.getVersion()) {
case V2_1:
case V3_0:
int pos = value.indexOf(';');
if (pos < 0) {
throw new CannotParseException(11);
}
String latitudeStr = value.substring(0, pos);
String longitudeStr = value.substring(pos + 1);
Double latitude;
try {
latitude = Double.valueOf(latitudeStr);
} catch (NumberFormatException e) {
throw new CannotParseException(8, latitudeStr);
}
Double longitude;
try {
longitude = Double.valueOf(longitudeStr);
} catch (NumberFormatException e) {
throw new CannotParseException(10, longitudeStr);
}
return new Geo(latitude, longitude);
case V4_0:
value = VObjectPropertyValues.unescape(value);
return parseGeoUri(value);
}
return null;
}
use of ezvcard.io.CannotParseException in project ez-vcard by mangstadt.
the class TimezoneScribe method _parseXml.
@Override
protected Timezone _parseXml(XCardElement element, VCardParameters parameters, ParseContext context) {
String text = element.first(VCardDataType.TEXT);
if (text != null) {
return new Timezone(text);
}
String utcOffset = element.first(VCardDataType.UTC_OFFSET);
if (utcOffset != null) {
try {
return new Timezone(UtcOffset.parse(utcOffset));
} catch (IllegalArgumentException e) {
throw new CannotParseException(19);
}
}
throw missingXmlElements(VCardDataType.TEXT, VCardDataType.UTC_OFFSET);
}
Aggregations