Search in sources :

Example 1 with StructuredValueIterator

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

the class StructuredNameScribe method _parseJson.

@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;
}
Also used : StructuredName(ezvcard.property.StructuredName) StructuredValueIterator(com.github.mangstadt.vinnie.io.VObjectPropertyValues.StructuredValueIterator) SemiStructuredValueIterator(com.github.mangstadt.vinnie.io.VObjectPropertyValues.SemiStructuredValueIterator)

Example 2 with StructuredValueIterator

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

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

the class OrganizationScribe method _parseJson.

@Override
protected Organization _parseJson(JCardValue value, VCardDataType dataType, VCardParameters parameters, ParseContext context) {
    Organization property = new Organization();
    StructuredValueIterator it = new StructuredValueIterator(value.asStructured());
    while (it.hasNext()) {
        String next = it.nextValue();
        if (next != null) {
            property.getValues().add(next);
        }
    }
    return property;
}
Also used : Organization(ezvcard.property.Organization) StructuredValueIterator(com.github.mangstadt.vinnie.io.VObjectPropertyValues.StructuredValueIterator)

Example 4 with StructuredValueIterator

use of com.github.mangstadt.vinnie.io.VObjectPropertyValues.StructuredValueIterator in project vinnie by mangstadt.

the class VObjectPropertyValuesTest method StructuredValueIterator.

@Test
public void StructuredValueIterator() {
    StructuredValueIterator it = new StructuredValueIterator("one;two;;;three,four");
    assertTrue(it.hasNext());
    assertEquals("one", it.nextValue());
    assertTrue(it.hasNext());
    assertEquals(asList("two"), it.nextComponent());
    assertTrue(it.hasNext());
    assertNull(it.nextValue());
    assertTrue(it.hasNext());
    assertEquals(asList(), it.nextComponent());
    assertTrue(it.hasNext());
    assertEquals(asList("three", "four"), it.nextComponent());
    assertFalse(it.hasNext());
    assertNull(it.nextValue());
    assertEquals(asList(), it.nextComponent());
}
Also used : StructuredValueIterator(com.github.mangstadt.vinnie.io.VObjectPropertyValues.StructuredValueIterator) SemiStructuredValueIterator(com.github.mangstadt.vinnie.io.VObjectPropertyValues.SemiStructuredValueIterator) Test(org.junit.Test)

Example 5 with StructuredValueIterator

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

the class ClientPidMapScribe method _parseJson.

@Override
protected ClientPidMap _parseJson(JCardValue value, VCardDataType dataType, VCardParameters parameters, ParseContext context) {
    StructuredValueIterator it = new StructuredValueIterator(value.asStructured());
    String pid = it.nextValue();
    String uri = it.nextValue();
    return parse(pid, uri);
}
Also used : 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