String group = parsedLine.getGroup();
String value = parsedLine.getValue().trim();
String type = parsedLine.getTypeName().trim().toUpperCase();
List<ParameterType> paramTypes = parseParamTypesLine(parsedLine.getParameters());
VCardTypeName vCardTypeName = null;
//Extended Types are a bit special since they only start with X- and end with anything.
if(type.startsWith("X-")) {
vCardTypeName = VCardTypeName.XTENDED;
}
else {
try {
//Enums do not like hyphens so replace it with an underscore.
type = type.replaceAll("-", "_");
vCardTypeName = VCardTypeName.valueOf(type);
}
catch(IllegalArgumentException iae) {
if(vcard.isThrowExceptions()) {
throw new VCardParseException(iae.getMessage(), iae);
}
else {
handleError(vcard, "Unrecognizable type name \""+type+"\"", iae, ErrorSeverity.WARNING);
return;
}
}
}
switch (vCardTypeName)
{
case BEGIN:
{
parseBeginType(group, value, vcard);
break;
}
case END:
{
parseEndType(group, value, vcard);
break;
}
case VERSION:
{
parseVersionType(group, value, vcard);
break;
}
case FN:
{
parseFnType(group, value, paramTypes, vcard);
break;
}
case N:
{
parseNType(group, value, paramTypes, vcard);
break;
}
case NICKNAME:
{
parseNicknameType(group, value, paramTypes, vcard);
break;
}
case PHOTO:
{
parsePhotoType(group, value, paramTypes, vcard);
break;
}
case BDAY:
{
parseBDayType(group, value, paramTypes, vcard);
break;
}
case ADR:
{
parseAdrType(group, value, paramTypes, vcard);
break;
}
case LABEL:
{
parseLabelType(group, value, paramTypes, vcard);
break;
}
case TEL:
{
parseTelType(group, value, paramTypes, vcard);
break;
}
case EMAIL:
{
parseEmailType(group, value, paramTypes, vcard);
break;
}
case MAILER:
{
parseMailerType(group, value, paramTypes, vcard);
break;
}
case TZ:
{
parseTzType(group, value, paramTypes, vcard);
break;
}
case GEO:
{
parseGeoType(group, value, paramTypes, vcard);
break;
}
case TITLE:
{
parseTitleType(group, value, paramTypes, vcard);
break;
}
case ROLE:
{
parseRoleType(group, value, paramTypes, vcard);
break;
}
case LOGO:
{
parseLogoType(group, value, paramTypes, vcard);
break;
}
case AGENT:
{
//TODO parseAgentType(group, value, vcard);
break;
}
case ORG:
{
parseOrgType(group, value, paramTypes, vcard);
break;
}
case CATEGORIES:
{
parseCategoriesType(group, value, paramTypes, vcard);
break;
}
case NOTE:
{
parseNoteType(group, value, paramTypes, vcard);
break;
}
case PRODID:
{
parseProdIdType(group, value, paramTypes, vcard);
break;
}
case REV:
{
parseRevType(group, value, paramTypes, vcard);
break;
}
case SORT_STRING:
{
parseSortStringType(group, value, paramTypes, vcard);
break;
}
case SOUND:
{
parseSoundType(group, value, paramTypes, vcard);
break;
}
case UID:
{
parseUidType(group, value, paramTypes, vcard);
break;
}
case URL:
{
parseUrlType(group, value, paramTypes, vcard);
break;
}
case CLASS:
{
parseClassType(group, value, paramTypes, vcard);
break;
}
case KEY:
{
parseKeyType(group, value, paramTypes, vcard);
break;
}
case XTENDED:
{
parseXtendedType(group, value, type, paramTypes, vcard);
break;
}
case NAME:
{
parseNameType(group, value, paramTypes, vcard);
break;
}
case PROFILE:
{
parseProfileType(group, value, paramTypes, vcard);
break;
}
case SOURCE:
{
parseSourceType(group, value, paramTypes, vcard);
break;
}
case IMPP:
{
parseImppType(group, value, paramTypes, vcard);
break;
}
default:
{
throw new VCardParseException("Unhandled VCard type \""+vCardTypeName.getType()+"\"");
}
}
}