private void copyNames(Map<String, Object> map, VCard card) { String givenName = (String) map.get("givenName"); String surname = (String) map.get("surname"); StructuredName structuredName = new StructuredName(); structuredName.setFamily(surname); structuredName.setGiven(givenName); getString("middleName", map).ifPresent(v -> structuredName.getAdditionalNames().add(v)); getString("title", map).ifPresent(v -> structuredName.getPrefixes().add(v)); card.setStructuredName(structuredName); getString("displayName", map).ifPresent(card::setFormattedName); getString("nickName", map).ifPresent(card::setNickname); }
private void copyNames(VCard card, Map<String, Object> contact) { StructuredName structuredName = card.getStructuredName(); if (structuredName != null) { safeSet("givenName", structuredName.getGiven(), contact); safeSet("surname", structuredName.getFamily(), contact); // MS contacts only allows one middle name - take the first one if (!structuredName.getAdditionalNames().isEmpty()) { safeSet("middleName", structuredName.getAdditionalNames().get(0), contact); } // MS contacts only allows one prefix - take the first one if (!structuredName.getPrefixes().isEmpty()) { safeSet("title", structuredName.getPrefixes().get(0), contact); } } safeSet("displayName", card.getFormattedName(), contact); safeSet("nickName", card.getNickname(), contact); }
.forEach(suffix -> strucName.addProperty(VCARD4.hasHonorificSuffix, suffix)); structuredName.getAdditionalNames() .forEach(additional -> strucName.addProperty(VCARD4.hasAdditionalName, additional));
); structuredNameResource.listProperties(VCARD4.hasAdditionalName).forEachRemaining( additional -> structuredName.getAdditionalNames().add(additional.getString()) ); vcard.getStructuredNames().add(structuredName);
@Override protected JCardValue _writeJson(StructuredName property) { return JCardValue.structured(property.getFamily(), property.getGiven(), property.getAdditionalNames(), property.getPrefixes(), property.getSuffixes()); }
@Override protected StructuredName _parseHtml(HCardElement element, ParseContext context) { StructuredName property = new StructuredName(); property.setFamily(s(element.firstValue("family-name"))); property.setGiven(s(element.firstValue("given-name"))); property.getAdditionalNames().addAll(element.allValues("additional-name")); property.getPrefixes().addAll(element.allValues("honorific-prefix")); property.getSuffixes().addAll(element.allValues("honorific-suffix")); return property; }
@Override protected StructuredName _parseJson(JCardValue value, VCardDataType dataType, VCardParameters parameters, ParseContext context) { StructuredName property = new StructuredName(); StructuredValueIterator it = new StructuredValueIterator(value.asStructured()); property.setFamily(it.nextValue()); property.setGiven(it.nextValue()); property.getAdditionalNames().addAll(it.nextComponent()); property.getPrefixes().addAll(it.nextComponent()); property.getSuffixes().addAll(it.nextComponent()); return property; } }
@Override protected StructuredName _parseXml(XCardElement element, VCardParameters parameters, ParseContext context) { StructuredName property = new StructuredName(); property.setFamily(s(element.first("surname"))); property.setGiven(s(element.first("given"))); property.getAdditionalNames().addAll(element.all("additional")); property.getPrefixes().addAll(element.all("prefix")); property.getSuffixes().addAll(element.all("suffix")); return property; }
property.getAdditionalNames().add(next); property.setFamily(it.nextValue()); property.setGiven(it.nextValue()); property.getAdditionalNames().addAll(it.nextComponent()); property.getPrefixes().addAll(it.nextComponent()); property.getSuffixes().addAll(it.nextComponent());
@Override protected void _writeXml(StructuredName property, XCardElement parent) { parent.append("surname", property.getFamily()); //the XML element still needs to be printed if value == null parent.append("given", property.getGiven()); parent.append("additional", property.getAdditionalNames()); parent.append("prefix", property.getPrefixes()); parent.append("suffix", property.getSuffixes()); }
builder.append(property.getFamily()); builder.append(property.getGiven()); builder.append(join(property.getAdditionalNames(), ",")); builder.append(join(property.getPrefixes(), ",")); builder.append(join(property.getSuffixes(), ",")); builder.append(property.getFamily()); builder.append(property.getGiven()); builder.append(property.getAdditionalNames()); builder.append(property.getPrefixes()); builder.append(property.getSuffixes());