Search in sources :

Example 1 with Note

use of ezvcard.property.Note in project android by nextcloud.

the class ContactOperations method convertNotes.

private void convertNotes(List<NonEmptyContentValues> contentValues, VCard vcard) {
    for (Note note : vcard.getNotes()) {
        String noteValue = note.getValue();
        NonEmptyContentValues cv = new NonEmptyContentValues(ContactsContract.CommonDataKinds.Note.CONTENT_ITEM_TYPE);
        cv.put(ContactsContract.CommonDataKinds.Note.NOTE, noteValue);
        contentValues.add(cv);
    }
}
Also used : Note(ezvcard.property.Note)

Example 2 with Note

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

the class VCardTest method setProperty.

@Test
public void setProperty() {
    VCard vcard = new VCard();
    Note property1 = new Note("value");
    assertEquals(asList(), vcard.setProperty(property1));
    assertEquals(asList(property1), vcard.getProperties(Note.class));
    Note property2 = new Note("value2");
    assertEquals(asList(property1), vcard.setProperty(property2));
    assertEquals(asList(property2), vcard.getProperties(Note.class));
    Note property3 = new Note("value3");
    vcard.addProperty(property3);
    assertEquals(asList(property2, property3), vcard.getProperties(Note.class));
    Note property4 = new Note("value4");
    assertEquals(asList(property2, property3), vcard.setProperty(property4));
    assertEquals(asList(property4), vcard.getProperties(Note.class));
}
Also used : Note(ezvcard.property.Note) Test(org.junit.Test)

Example 3 with Note

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

the class VCardTest method removeProperty.

@Test
public void removeProperty() {
    VCard vcard = new VCard();
    Note property1 = new Note("value");
    assertFalse(vcard.removeProperty(property1));
    vcard.addProperty(property1);
    assertEquals(asList(property1), vcard.getProperties(Note.class));
    assertTrue(vcard.removeProperty(property1));
    assertEquals(asList(), vcard.getProperties(Note.class));
}
Also used : Note(ezvcard.property.Note) Test(org.junit.Test)

Example 4 with Note

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

the class SampleVCardsTest method outlook2003VCard.

@Test
public void outlook2003VCard() throws Throwable {
    VCardAsserter asserter = read("outlook-2003.vcf");
    asserter.next(V2_1);
    // @formatter:off
    asserter.structuredName().family("Doe").given("John").prefixes("Mr.").suffixes("III").noMore();
    asserter.simpleProperty(FormattedName.class).value("John Doe III").noMore();
    asserter.listProperty(Nickname.class).values("Joey").noMore();
    asserter.listProperty(Organization.class).values("Company, The", "TheDepartment").noMore();
    asserter.simpleProperty(Title.class).value("The Job Title").noMore();
    asserter.simpleProperty(Note.class).value("This is the note field!!\r\nSecond line\r\n\r\nThird line is empty\r\n").param("ENCODING", "QUOTED-PRINTABLE").noMore();
    asserter.telephone().types(TelephoneType.WORK, TelephoneType.VOICE).text("BusinessPhone").next().types(TelephoneType.HOME, TelephoneType.VOICE).text("HomePhone").next().types(TelephoneType.CELL, TelephoneType.VOICE).text("MobilePhone").next().types(TelephoneType.WORK, TelephoneType.FAX).text("BusinessFaxPhone").noMore();
    asserter.address().extendedAddress("TheOffice").streetAddress("123 Main St").locality("Austin").region("TX").postalCode("12345").country("United States of America").label("TheOffice\r\n123 Main St\r\nAustin, TX 12345\r\nUnited States of America").types(AddressType.WORK).noMore();
    asserter.simpleProperty(Url.class).value("http://web-page-address.com").param("TYPE", "WORK").noMore();
    asserter.simpleProperty(Role.class).value("TheProfession").noMore();
    asserter.dateProperty(Birthday.class).date("1980-03-21").noMore();
    asserter.binaryProperty(Key.class).param("ENCODING", "BASE64").param("TYPE", "X509").contentType(KeyType.X509).dataLength(805).noMore();
    asserter.email().types(EmailType.PREF, EmailType.INTERNET).value("jdoe@hotmail.com").noMore();
    /*
		 * Outlook 2003 apparently doesn't output FBURL correctly:
		 * http://help.lockergnome.com/office/BUG-Outlook-2003-exports-FBURL-vCard-incorrectly--ftopict423660.html
		 */
    asserter.simpleProperty(FreeBusyUrl.class).value("????????????????s????????????" + (char) 12).param("ENCODING", "QUOTED-PRINTABLE").noMore();
    asserter.simpleProperty(Revision.class).value(utc("2012-10-12 21:05:25")).noMore();
    VCard vcard = asserter.getVCard();
    asserter.validate().prop(vcard.getNickname(), // not supported in 2.1
    2).prop(vcard.getFbUrls().get(0), // not supported in 2.1
    2).run();
    // @formatter:on
    asserter.done();
}
Also used : Note(ezvcard.property.Note) FreeBusyUrl(ezvcard.property.FreeBusyUrl) VCardAsserter(ezvcard.property.asserter.VCardAsserter) VCard(ezvcard.VCard) FreeBusyUrl(ezvcard.property.FreeBusyUrl) Url(ezvcard.property.Url) Key(ezvcard.property.Key) Test(org.junit.Test)

Example 5 with Note

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

the class XCardDocumentTest method add_group.

@Test
public void add_group() throws Throwable {
    VCard vcard = new VCard();
    vcard.setFormattedName("John Doe");
    Note note = vcard.addNote("This is a\nnote.");
    note.setGroup("group1");
    note.setLanguage("en");
    Photo photo = new Photo("http://example.com/image.jpg", ImageType.JPEG);
    photo.setGroup("group1");
    vcard.addPhoto(photo);
    note = vcard.addNote("Bonjour.");
    note.setGroup("group2");
    XCardDocument xcard = new XCardDocument();
    XCardDocumentStreamWriter writer = xcard.writer();
    writer.setAddProdId(false);
    writer.write(vcard);
    Document actual = xcard.getDocument();
    // @formatter:off
    String xml = "<vcards xmlns=\"" + V4_0.getXmlNamespace() + "\">" + "<vcard>" + "<fn><text>John Doe</text></fn>" + "<group name=\"group1\">" + "<photo>" + "<parameters>" + "<mediatype><text>image/jpeg</text></mediatype>" + "</parameters>" + "<uri>http://example.com/image.jpg</uri>" + "</photo>" + "<note>" + "<parameters>" + "<language><language-tag>en</language-tag></language>" + "</parameters>" + "<text>This is a\nnote.</text>" + "</note>" + "</group>" + "<group name=\"group2\">" + "<note><text>Bonjour.</text></note>" + "</group>" + "</vcard>" + "</vcards>";
    Document expected = XmlUtils.toDocument(xml);
    // @formatter:on
    assertXMLEqual(expected, actual);
}
Also used : Note(ezvcard.property.Note) XCardDocumentStreamWriter(ezvcard.io.xml.XCardDocument.XCardDocumentStreamWriter) Photo(ezvcard.property.Photo) Document(org.w3c.dom.Document) VCard(ezvcard.VCard) Test(org.junit.Test)

Aggregations

Note (ezvcard.property.Note)21 Test (org.junit.Test)18 VCard (ezvcard.VCard)9 VCardAsserter (ezvcard.property.asserter.VCardAsserter)6 FormattedName (ezvcard.property.FormattedName)4 Photo (ezvcard.property.Photo)4 XCardDocumentStreamWriter (ezvcard.io.xml.XCardDocument.XCardDocumentStreamWriter)2 Pid (ezvcard.parameter.Pid)2 Title (ezvcard.property.Title)2 Url (ezvcard.property.Url)2 StringWriter (java.io.StringWriter)2 Document (org.w3c.dom.Document)2 Address (ezvcard.property.Address)1 Agent (ezvcard.property.Agent)1 Categories (ezvcard.property.Categories)1 Email (ezvcard.property.Email)1 FreeBusyUrl (ezvcard.property.FreeBusyUrl)1 Impp (ezvcard.property.Impp)1 Key (ezvcard.property.Key)1 Nickname (ezvcard.property.Nickname)1