Search in sources :

Example 1 with Gender

use of ezvcard.property.Gender 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 Gender

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

the class GenderScribe method _parseJson.

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

Example 3 with Gender

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

the class GenderScribe method _parseXml.

@Override
protected Gender _parseXml(XCardElement element, VCardParameters parameters, ParseContext context) {
    String sex = element.first("sex");
    if (sex != null) {
        Gender property = new Gender(sex);
        // optional field
        property.setText(element.first("identity"));
        return property;
    }
    throw missingXmlElements("sex");
}
Also used : Gender(ezvcard.property.Gender)

Aggregations

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