Search in sources :

Example 36 with StructuredName

use of ezvcard.property.StructuredName in project ez-vcard by mangstadt.

the class StructuredNameScribe method _parseText.

@Override
protected StructuredName _parseText(String value, VCardDataType dataType, VCardParameters parameters, ParseContext context) {
    StructuredName property = new StructuredName();
    if (context.getVersion() == VCardVersion.V2_1) {
        /*
			 * 2.1 does not recognize multi-valued components.
			 */
        SemiStructuredValueIterator it = new SemiStructuredValueIterator(value);
        property.setFamily(it.next());
        property.setGiven(it.next());
        String next = it.next();
        if (next != null) {
            property.getAdditionalNames().add(next);
        }
        next = it.next();
        if (next != null) {
            property.getPrefixes().add(next);
        }
        next = it.next();
        if (next != null) {
            property.getSuffixes().add(next);
        }
    } else {
        StructuredValueIterator it = new StructuredValueIterator(value);
        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;
}
Also used : SemiStructuredValueIterator(com.github.mangstadt.vinnie.io.VObjectPropertyValues.SemiStructuredValueIterator) StructuredName(ezvcard.property.StructuredName) StructuredValueIterator(com.github.mangstadt.vinnie.io.VObjectPropertyValues.StructuredValueIterator) SemiStructuredValueIterator(com.github.mangstadt.vinnie.io.VObjectPropertyValues.SemiStructuredValueIterator)

Example 37 with StructuredName

use of ezvcard.property.StructuredName in project ez-vcard by mangstadt.

the class StructuredNameScribe method _parseXml.

@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;
}
Also used : StructuredName(ezvcard.property.StructuredName)

Aggregations

StructuredName (ezvcard.property.StructuredName)37 VCard (ezvcard.VCard)17 Telephone (ezvcard.property.Telephone)14 Test (org.junit.Test)13 Address (ezvcard.property.Address)11 Name (com.google.api.services.people.v1.model.Name)10 Email (ezvcard.property.Email)9 Person (com.google.api.services.people.v1.model.Person)8 EmailAddress (com.google.api.services.people.v1.model.EmailAddress)6 FieldMetadata (com.google.api.services.people.v1.model.FieldMetadata)6 PhoneNumber (com.google.api.services.people.v1.model.PhoneNumber)6 Source (com.google.api.services.people.v1.model.Source)6 Timezone (ezvcard.property.Timezone)6 TelUri (ezvcard.util.TelUri)6 UtcOffset (ezvcard.util.UtcOffset)6 Collections (java.util.Collections)6 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 Birthday (ezvcard.property.Birthday)5 Truth.assertThat (com.google.common.truth.Truth.assertThat)4