Search in sources :

Example 6 with Organization

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

the class OrganizationScribe method _parseXml.

@Override
protected Organization _parseXml(XCardElement element, VCardParameters parameters, ParseContext context) {
    List<String> values = element.all(VCardDataType.TEXT);
    if (!values.isEmpty()) {
        Organization property = new Organization();
        property.getValues().addAll(values);
        return property;
    }
    throw missingXmlElements(VCardDataType.TEXT);
}
Also used : Organization(ezvcard.property.Organization)

Example 7 with Organization

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

the class OrganizationScribe method _parseHtml.

@Override
protected Organization _parseHtml(HCardElement element, ParseContext context) {
    Organization property = new Organization();
    String orgName = element.firstValue("organization-name");
    if (orgName != null) {
        property.getValues().add(orgName);
    }
    String orgUnit = element.firstValue("organization-unit");
    if (orgUnit != null) {
        property.getValues().add(orgUnit);
    }
    if (property.getValues().isEmpty()) {
        String value = element.value();
        if (value.length() > 0) {
            property.getValues().add(value);
        }
    }
    return property;
}
Also used : Organization(ezvcard.property.Organization)

Example 8 with Organization

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

the class OrganizationScribeTest method parseHtml.

@Test
public void parseHtml() {
    // @formatter:off
    sensei.assertParseHtml("<div>" + "<span class=\"organization-name\">one,two;three</span>" + "<span class=\"organization-unit\">four</span>" + "</div>").run(withMultipleValues);
    sensei.assertParseHtml("<div>" + "<span class=\"organization-name\">one,two;three</span>" + "</div>").run(withOneValue);
    Organization withUnit = new Organization(withMultipleValues);
    withUnit.getValues().remove(0);
    sensei.assertParseHtml("<div>" + "<span class=\"organization-unit\">four</span>" + "</div>").run(withUnit);
    Organization withTextContent = new Organization();
    withTextContent.getValues().add("name");
    sensei.assertParseHtml("<div>name</div>").run(withTextContent);
    sensei.assertParseHtml("<div>" + "</div>").run(empty);
// @formatter:on
}
Also used : Organization(ezvcard.property.Organization) Test(org.junit.Test)

Example 9 with Organization

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

the class VCard method setOrganization.

/**
 * <p>
 * Sets the hierarchy of departments to which the person belongs.
 * </p>
 * <p>
 * <b>Property name:</b> {@code ORG}<br>
 * <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
 * </p>
 * @param departments the ordered list of department(s), starting with the
 * broadest and ending with the most specific (e.g. "Google", "Gmail Team",
 * "Spam Detection Squad") or an empty arguments list to remove
 * @return the property object that was created
 * @see <a href="http://tools.ietf.org/html/rfc6350#page-40">RFC 6350
 * p.40</a>
 * @see <a href="http://tools.ietf.org/html/rfc2426#page-20">RFC 2426
 * p.20</a>
 * @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.19</a>
 */
public Organization setOrganization(String... departments) {
    Organization type = null;
    if (departments.length > 0) {
        type = new Organization();
        type.getValues().addAll(Arrays.asList(departments));
    }
    setOrganization(type);
    return type;
}
Also used : Organization(ezvcard.property.Organization)

Aggregations

Organization (ezvcard.property.Organization)9 Title (ezvcard.property.Title)2 StructuredValueIterator (com.github.mangstadt.vinnie.io.VObjectPropertyValues.StructuredValueIterator)1 Test (org.junit.Test)1