Search in sources :

Example 6 with RawProperty

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

the class RawPropertyScribe method _parseText.

@Override
protected RawProperty _parseText(String value, VCardDataType dataType, VCardParameters parameters, ParseContext context) {
    RawProperty property = new RawProperty(propertyName, value);
    property.setDataType(dataType);
    return property;
}
Also used : RawProperty(ezvcard.property.RawProperty)

Example 7 with RawProperty

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

the class VCard method removeExtendedProperty.

/**
 * Removes all extended properties that have the given name.
 * @param name the component name (e.g. "X-ALT-DESC")
 * @return the properties that were removed (this list is immutable)
 */
public List<RawProperty> removeExtendedProperty(String name) {
    List<RawProperty> all = getExtendedProperties();
    List<RawProperty> toRemove = new ArrayList<RawProperty>();
    for (RawProperty property : all) {
        if (property.getPropertyName().equalsIgnoreCase(name)) {
            toRemove.add(property);
        }
    }
    all.removeAll(toRemove);
    return Collections.unmodifiableList(toRemove);
}
Also used : RawProperty(ezvcard.property.RawProperty) ArrayList(java.util.ArrayList)

Example 8 with RawProperty

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

the class VCardTest method setExtendedProperty.

@Test
public void setExtendedProperty() {
    VCard vcard = new VCard();
    assertEquals(asList(), vcard.getExtendedProperties());
    RawProperty property = vcard.setExtendedProperty("NAME", "value");
    assertEquals("NAME", property.getPropertyName());
    assertEquals("value", property.getValue());
    assertNull(property.getDataType());
    assertEquals(asList(property), vcard.getExtendedProperties());
    RawProperty property2 = vcard.setExtendedProperty("NAME", "value", VCardDataType.TEXT);
    assertEquals("NAME", property2.getPropertyName());
    assertEquals("value", property2.getValue());
    assertEquals(VCardDataType.TEXT, property2.getDataType());
    assertEquals(asList(property2), vcard.getExtendedProperties());
}
Also used : RawProperty(ezvcard.property.RawProperty) Test(org.junit.Test)

Example 9 with RawProperty

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

the class VCardTest method addExtendedProperty.

@Test
public void addExtendedProperty() {
    VCard vcard = new VCard();
    assertEquals(asList(), vcard.getExtendedProperties());
    RawProperty property = vcard.addExtendedProperty("NAME", "value");
    assertEquals("NAME", property.getPropertyName());
    assertEquals("value", property.getValue());
    assertNull(property.getDataType());
    assertEquals(asList(property), vcard.getExtendedProperties());
    RawProperty property2 = vcard.addExtendedProperty("NAME", "value", VCardDataType.TEXT);
    assertEquals("NAME", property2.getPropertyName());
    assertEquals("value", property2.getValue());
    assertEquals(VCardDataType.TEXT, property2.getDataType());
    assertEquals(asList(property, property2), vcard.getExtendedProperties());
}
Also used : RawProperty(ezvcard.property.RawProperty) Test(org.junit.Test)

Example 10 with RawProperty

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

the class VCardTest method getExtendedProperty.

@Test
public void getExtendedProperty() {
    VCard vcard = new VCard();
    assertNull(vcard.getExtendedProperty("NAME"));
    vcard.addExtendedProperty("NAME2", "value");
    assertNull(vcard.getExtendedProperty("NAME"));
    RawProperty property = vcard.addExtendedProperty("NAME", "value");
    assertEquals(property, vcard.getExtendedProperty("NAME"));
    assertEquals(property, vcard.getExtendedProperty("name"));
    vcard.addExtendedProperty("NAME", "value2");
    assertEquals(property, vcard.getExtendedProperty("NAME"));
}
Also used : RawProperty(ezvcard.property.RawProperty) Test(org.junit.Test)

Aggregations

RawProperty (ezvcard.property.RawProperty)22 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)4 VCard (ezvcard.VCard)3 VCardVersion (ezvcard.VCardVersion)3 FormattedName (ezvcard.property.FormattedName)3 Impp (ezvcard.property.Impp)3 VCardProperty (ezvcard.property.VCardProperty)3 LuckyNumProperty (ezvcard.io.LuckyNumProperty)2 LuckyNumScribe (ezvcard.io.LuckyNumProperty.LuckyNumScribe)2 Label (ezvcard.property.Label)2 ProductId (ezvcard.property.ProductId)2 StructuredName (ezvcard.property.StructuredName)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 VCardDataType (ezvcard.VCardDataType)1 AgeProperty (ezvcard.io.AgeProperty)1 AgeScribe (ezvcard.io.AgeProperty.AgeScribe)1 CannotParseException (ezvcard.io.CannotParseException)1