Search in sources :

Example 1 with SemiStructuredValueIterator

use of com.github.mangstadt.vinnie.io.VObjectPropertyValues.SemiStructuredValueIterator in project ez-vcard by mangstadt.

the class GenderScribe method _parseText.

@Override
protected Gender _parseText(String value, VCardDataType dataType, VCardParameters parameters, ParseContext context) {
    SemiStructuredValueIterator it = new SemiStructuredValueIterator(value, 2);
    String sex = it.next();
    if (sex != null) {
        sex = sex.toUpperCase();
    }
    String text = it.next();
    Gender property = new Gender(sex);
    property.setText(text);
    return property;
}
Also used : SemiStructuredValueIterator(com.github.mangstadt.vinnie.io.VObjectPropertyValues.SemiStructuredValueIterator) Gender(ezvcard.property.Gender)

Example 2 with SemiStructuredValueIterator

use of com.github.mangstadt.vinnie.io.VObjectPropertyValues.SemiStructuredValueIterator in project ez-vcard by mangstadt.

the class ClientPidMapScribe method _parseText.

@Override
protected ClientPidMap _parseText(String value, VCardDataType dataType, VCardParameters parameters, ParseContext context) {
    SemiStructuredValueIterator it = new SemiStructuredValueIterator(value, 2);
    String pid = it.next();
    String uri = it.next();
    if (pid == null || uri == null) {
        throw new CannotParseException(3);
    }
    return parse(pid, uri);
}
Also used : CannotParseException(ezvcard.io.CannotParseException) SemiStructuredValueIterator(com.github.mangstadt.vinnie.io.VObjectPropertyValues.SemiStructuredValueIterator)

Example 3 with SemiStructuredValueIterator

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

SemiStructuredValueIterator (com.github.mangstadt.vinnie.io.VObjectPropertyValues.SemiStructuredValueIterator)3 StructuredValueIterator (com.github.mangstadt.vinnie.io.VObjectPropertyValues.StructuredValueIterator)1 CannotParseException (ezvcard.io.CannotParseException)1 Gender (ezvcard.property.Gender)1 StructuredName (ezvcard.property.StructuredName)1