Search in sources :

Example 6 with StructuredValueIterator

use of com.github.mangstadt.vinnie.io.VObjectPropertyValues.StructuredValueIterator 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)

Aggregations

StructuredValueIterator (com.github.mangstadt.vinnie.io.VObjectPropertyValues.StructuredValueIterator)6 SemiStructuredValueIterator (com.github.mangstadt.vinnie.io.VObjectPropertyValues.SemiStructuredValueIterator)5 StructuredName (ezvcard.property.StructuredName)2 Gender (ezvcard.property.Gender)1 Organization (ezvcard.property.Organization)1 Test (org.junit.Test)1