Search in sources :

Example 6 with Geo

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

the class JCardWriterTest method createExample.

public static VCard createExample() {
    VCard vcard = new VCard();
    vcard.setFormattedName("SimonPerreault");
    StructuredName n = new StructuredName();
    n.setFamily("Perreault");
    n.setGiven("Simon");
    n.getSuffixes().add("ing.jr");
    n.getSuffixes().add("M.Sc.");
    vcard.setStructuredName(n);
    Birthday bday = new Birthday(PartialDate.builder().month(2).date(3).build());
    vcard.setBirthday(bday);
    Anniversary anniversary = new Anniversary(PartialDate.builder().year(2009).month(8).date(8).hour(14).minute(30).second(0).offset(new UtcOffset(false, -5, 0)).build());
    vcard.setAnniversary(anniversary);
    vcard.setGender(Gender.male());
    vcard.addLanguage("fr").setPref(1);
    vcard.addLanguage("en").setPref(2);
    vcard.setOrganization("Viagenie").setType("work");
    Address adr = new Address();
    adr.setExtendedAddress("SuiteD2-630");
    adr.setStreetAddress("2875Laurier");
    adr.setLocality("Quebec");
    adr.setRegion("QC");
    adr.setPostalCode("G1V2M2");
    adr.setCountry("Canada");
    adr.getTypes().add(AddressType.WORK);
    vcard.addAddress(adr);
    TelUri telUri = new TelUri.Builder("+1-418-656-9254").extension("102").build();
    Telephone tel = new Telephone(telUri);
    tel.getTypes().add(TelephoneType.WORK);
    tel.getTypes().add(TelephoneType.VOICE);
    tel.setPref(1);
    vcard.addTelephoneNumber(tel);
    tel = new Telephone(new TelUri.Builder("+1-418-262-6501").build());
    tel.getTypes().add(TelephoneType.WORK);
    tel.getTypes().add(TelephoneType.CELL);
    tel.getTypes().add(TelephoneType.VOICE);
    tel.getTypes().add(TelephoneType.VIDEO);
    tel.getTypes().add(TelephoneType.TEXT);
    vcard.addTelephoneNumber(tel);
    vcard.addEmail("simon.perreault@viagenie.ca", EmailType.WORK);
    Geo geo = new Geo(46.772673, -71.282945);
    geo.setType("work");
    vcard.setGeo(geo);
    Key key = new Key("http://www.viagenie.ca/simon.perreault/simon.asc", null);
    key.setType("work");
    vcard.addKey(key);
    vcard.setTimezone(new Timezone(new UtcOffset(false, -5, 0)));
    vcard.addUrl("http://nomis80.org").setType("home");
    return vcard;
}
Also used : Timezone(ezvcard.property.Timezone) Address(ezvcard.property.Address) Telephone(ezvcard.property.Telephone) Anniversary(ezvcard.property.Anniversary) TelUri(ezvcard.util.TelUri) Birthday(ezvcard.property.Birthday) Geo(ezvcard.property.Geo) UtcOffset(ezvcard.util.UtcOffset) VCard(ezvcard.VCard) StructuredName(ezvcard.property.StructuredName) Key(ezvcard.property.Key)

Example 7 with Geo

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

the class VCard method setGeo.

/**
 * <p>
 * Sets the geographical position of where the person lives/works.
 * </p>
 * <p>
 * <b>Property name:</b> {@code GEO}<br>
 * <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
 * </p>
 * @param latitude the latitude
 * @param longitude the longitude
 * @return the property object that was created
 * @see <a href="http://tools.ietf.org/html/rfc6350#page-38">RFC 6350
 * p.38</a>
 * @see <a href="http://tools.ietf.org/html/rfc2426#page-16">RFC 2426
 * p.16</a>
 * @see <a href="http://www.imc.org/pdi/vcard-21.doc">vCard 2.1 p.16</a>
 */
public Geo setGeo(double latitude, double longitude) {
    Geo type = new Geo(latitude, longitude);
    setGeo(type);
    return type;
}
Also used : Geo(ezvcard.property.Geo)

Aggregations

Geo (ezvcard.property.Geo)7 VCard (ezvcard.VCard)4 Address (ezvcard.property.Address)4 Anniversary (ezvcard.property.Anniversary)4 Birthday (ezvcard.property.Birthday)4 Key (ezvcard.property.Key)4 StructuredName (ezvcard.property.StructuredName)4 Telephone (ezvcard.property.Telephone)4 Timezone (ezvcard.property.Timezone)4 TelUri (ezvcard.util.TelUri)4 UtcOffset (ezvcard.util.UtcOffset)4 Test (org.junit.Test)3 CannotParseException (ezvcard.io.CannotParseException)2 StringWriter (java.io.StringWriter)1