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));
}
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));
}
use of ezvcard.property.Note in project qksms by moezbhatti.
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);
}
}
use of ezvcard.property.Note in project ez-vcard by mangstadt.
the class SampleVCardsTest method thunderbird.
@Test
public void thunderbird() throws Throwable {
VCardAsserter asserter = read("thunderbird-MoreFunctionsForAddressBook-extension.vcf");
asserter.next(V3_0);
// @formatter:off
asserter.structuredName().param("CHARSET", "UTF-8").family("Doe").given("John").noMore();
asserter.simpleProperty(FormattedName.class).param("CHARSET", "UTF-8").value("John Doe").noMore();
asserter.listProperty(Organization.class).param("CHARSET", "UTF-8").values("TheOrganization", "TheDepartment").noMore();
asserter.listProperty(Nickname.class).param("CHARSET", "UTF-8").values("Johnny").noMore();
asserter.address().param("CHARSET", "UTF-8").extendedAddress("222 Broadway").streetAddress("Suite 100").locality("New York").region("NY").postalCode("98765").country("USA").types(AddressType.WORK, AddressType.POSTAL).next().param("CHARSET", "UTF-8").extendedAddress("123 Main St").streetAddress("Apt 10").locality("Austin").region("TX").postalCode("12345").country("USA").types(AddressType.HOME, AddressType.POSTAL).noMore();
asserter.telephone().types(TelephoneType.WORK, TelephoneType.VOICE).text("555-555-1111").next().types(TelephoneType.HOME, TelephoneType.VOICE).text("555-555-2222").next().types(TelephoneType.CELL, TelephoneType.VOICE).text("555-555-5555").next().types(TelephoneType.FAX).text("555-555-3333").next().types(TelephoneType.PAGER).text("555-555-4444").noMore();
asserter.email().types(EmailType.PREF, EmailType.INTERNET).value("doe.john@hotmail.com").next().types(EmailType.INTERNET).value("additional-email@company.com").next().types(EmailType.INTERNET).value("additional-email1@company.com").next().types(EmailType.INTERNET).value("additional-email2@company.com").next().types(EmailType.INTERNET).value("additional-email3@company.com").noMore();
asserter.simpleProperty(Url.class).value("http://www.private-webpage.com").param("TYPE", "HOME").next().value("http://www.work-webpage.com").param("TYPE", "WORK").noMore();
asserter.simpleProperty(Title.class).param("CHARSET", "UTF-8").value("TheTitle").noMore();
asserter.listProperty(Categories.class).param("CHARSET", "UTF-8").values(// commas are incorrectly escaped, so there is only 1 item
"category1, category2, category3").noMore();
asserter.dateProperty(Birthday.class).date("1970-09-21").noMore();
asserter.simpleProperty(Note.class).param("CHARSET", "UTF-8").value("This is the notes field." + NEWLINE + "Second Line" + NEWLINE + NEWLINE + "Fourth Line" + NEWLINE + "You can put anything in the \"note\" field; even curse words.").noMore();
asserter.binaryProperty(Photo.class).param("ENCODING", "b").param("TYPE", "JPEG").contentType(ImageType.JPEG).dataLength(8940).noMore();
asserter.rawProperty("X-SPOUSE").value("TheSpouse").noMore();
asserter.rawProperty("X-ANNIVERSARY").value("1990-04-30").noMore();
VCard vcard = asserter.getVCard();
asserter.validate().prop(vcard.getStructuredName(), // CHARSET not supported in 3.0
6).prop(vcard.getFormattedName(), // CHARSET not supported in 3.0
6).prop(vcard.getOrganization(), // CHARSET not supported in 3.0
6).prop(vcard.getNickname(), // CHARSET not supported in 3.0
6).prop(vcard.getAddresses().get(0), // CHARSET not supported in 3.0
6).prop(vcard.getAddresses().get(1), // CHARSET not supported in 3.0
6).prop(vcard.getTitles().get(0), // CHARSET not supported in 3.0
6).prop(vcard.getCategories(), // CHARSET not supported in 3.0
6).prop(vcard.getNotes().get(0), // CHARSET not supported in 3.0
6).run();
// @formatter:on
asserter.done();
}
use of ezvcard.property.Note in project ez-vcard by mangstadt.
the class VCardWriterTest method embeddedVCard.
@Test
public void embeddedVCard() throws Throwable {
VCard vcard = new VCard();
vcard.setFormattedName("Michael Angstadt");
VCard agentVcard = new VCard();
agentVcard.setFormattedName("Agent 007");
Note note = agentVcard.addNote("Bonne soir�e, 007.");
note.setLanguage("fr");
Agent agent = new Agent(agentVcard);
vcard.setAgent(agent);
// i herd u liek AGENTs...
VCard secondAgentVCard = new VCard();
secondAgentVCard.setFormattedName("Agent 009");
note = secondAgentVCard.addNote("Good evening, 009.");
note.setLanguage("en");
Agent secondAgent = new Agent(secondAgentVCard);
agentVcard.setAgent(secondAgent);
StringWriter sw = new StringWriter();
VCardWriter vcw = new VCardWriter(sw, VCardVersion.V3_0);
vcw.getVObjectWriter().getFoldedLineWriter().setLineLength(null);
vcw.setAddProdId(false);
vcw.write(vcard);
String actual = sw.toString();
// @formatter:off
String expected = "BEGIN:VCARD\r\n" + "VERSION:3.0\r\n" + "FN:Michael Angstadt\r\n" + // nested types should not have PRODID
"AGENT:" + "BEGIN:VCARD\\n" + "VERSION:3.0\\n" + "FN:Agent 007\\n" + "NOTE\\;LANGUAGE=fr:Bonne soir�e\\\\\\, 007.\\n" + "AGENT:" + "BEGIN:VCARD\\\\n" + "VERSION:3.0\\\\n" + "FN:Agent 009\\\\n" + "NOTE\\\\\\;LANGUAGE=en:Good evening\\\\\\\\\\\\\\, 009.\\\\n" + "END:VCARD\\\\n\\n" + "END:VCARD\\n\r\n" + "END:VCARD\r\n";
// @formatter:on
assertEquals(expected, actual);
}
Aggregations