@Override public Agent copy() { return new Agent(this); }
@Override protected VCardDataType _dataType(Agent property, VCardVersion version) { if (property.getUrl() != null) { return (version == VCardVersion.V2_1) ? VCardDataType.URL : VCardDataType.URI; } return null; }
/** * Creates an agent property. * @param url a URL pointing to the agent's information */ public Agent(String url) { setUrl(url); }
@Override protected Agent _parseText(String value, VCardDataType dataType, VCardParameters parameters, ParseContext context) { Agent property = new Agent(); if (dataType == null) { throw new EmbeddedVCardException(new Injector(property)); } property.setUrl(VObjectPropertyValues.unescape(value)); return property; }
@Override protected String _writeText(Agent property, WriteContext context) { String url = property.getUrl(); if (url != null) { return url; } VCard vcard = property.getVCard(); if (vcard != null) { throw new EmbeddedVCardException(vcard); } //don't write an empty value because parsers could interpret that as there being an embedded vCard on the next line throw new SkipMeException(Messages.INSTANCE.getValidationWarning(8)); }
/** * Creates an agent property. * @param vcard a vCard containing the agent's information */ public Agent(VCard vcard) { setVCard(vcard); }
@Override protected Agent _parseHtml(HCardElement element, ParseContext context) { Agent property = new Agent(); Set<String> classes = element.classNames(); if (classes.contains("vcard")) { throw new EmbeddedVCardException(new Injector(property)); } String url = element.absUrl("href"); if (url.length() == 0) { url = element.value(); } property.setUrl(url); return property; }
public void injectVCard(VCard vcard) { property.setVCard(vcard); }