Package net.sourceforge.cardme.vcard

Examples of net.sourceforge.cardme.vcard.VCardImpl


    assertTrue(vcardStr.contains("REV:2011-12-22T14:30:05Z\r\n"));
  }
 
  @Test
  public void testBuildUidType() throws VCardBuildException {
    VCardImpl vcard = getSimpleVCard();
    vcard.setUid(new UidType("c0ff639f-9633-4e57-bcfd-55079cfd9d65"));
   
    VCardWriter vcardWriter = new VCardWriter();
    vcardWriter.setOutputVersion(VCardVersion.V3_0);
    vcardWriter.setCompatibilityMode(CompatibilityMode.RFC2426);
    vcardWriter.setFoldingScheme(FoldingScheme.MIME_DIR);
View Full Code Here


    Calendar bday = Calendar.getInstance();
    bday.set(Calendar.YEAR, 1980);
    bday.set(Calendar.MONTH, 4);
    bday.set(Calendar.DAY_OF_MONTH, 21);
   
    VCardImpl vcard = getSimpleVCard();
    BDayType bdayType = new BDayType(bday);
    bdayType.setParam(BDayParamType.DATE);
    vcard.setBDay(bdayType);
   
    VCardWriter vcardWriter = new VCardWriter();
    vcardWriter.setOutputVersion(VCardVersion.V3_0);
    vcardWriter.setCompatibilityMode(CompatibilityMode.RFC2426);
    vcardWriter.setFoldingScheme(FoldingScheme.MIME_DIR);
View Full Code Here

    assertTrue(vcardStr.contains("BDAY;VALUE=DATE:1980-05-21\r\n"));
  }
 
  @Test
  public void testBuildAdrType() throws VCardBuildException {
    VCardImpl vcard = getSimpleVCard();
    AdrType adr = new AdrType();
    adr.setPostOfficeBox("25334");
    adr.setStreetAddress("South cresent drive, Building 5, 3rd floor");
    adr.setLocality("New York");
    adr.setRegion("New York");
    adr.setPostalCode("NYC887");
    adr.setCountryName("U.S.A.");
    adr.addParam(AdrParamType.HOME).addParam(AdrParamType.PARCEL).addParam(AdrParamType.PREF);
    vcard.addAdr(adr);
   
    VCardWriter vcardWriter = new VCardWriter();
    vcardWriter.setOutputVersion(VCardVersion.V3_0);
    vcardWriter.setCompatibilityMode(CompatibilityMode.RFC2426);
    vcardWriter.setFoldingScheme(FoldingScheme.MIME_DIR);
View Full Code Here

    assertTrue(vcardStr.contains("ADR;TYPE=HOME,PARCEL,PREF:25334;;South cresent drive\\, Building 5\\, 3rd flo\r\n or;New York;New York;NYC887;U.S.A.\r\n"));
  }
 
  @Test
  public void testBuildKeyType() throws VCardBuildException {
    VCardImpl vcard = getSimpleVCard();
   
    KeyType keyPlain = new KeyType();
    keyPlain.setKeyTextType(KeyTextType.PGP);
    keyPlain.setKey("plain text key");
    vcard.addKey(keyPlain);
   
    KeyType keyBin = new KeyType();
    keyBin.setKeyTextType(KeyTextType.X509);
    keyBin.setEncodingType(EncodingType.BINARY);
    keyBin.setKey("binary data".getBytes());
    vcard.addKey(keyBin);
   
    VCardWriter vcardWriter = new VCardWriter();
    vcardWriter.setOutputVersion(VCardVersion.V3_0);
    vcardWriter.setCompatibilityMode(CompatibilityMode.RFC2426);
    vcardWriter.setFoldingScheme(FoldingScheme.MIME_DIR);
View Full Code Here

    assertTrue(vcardStr.contains("KEY;ENCODING=B;TYPE=X509:YmluYXJ5IGRhdGE=\r\n"));
  }
 
  private VCardImpl getSimpleVCard()
  {
    VCardImpl vcard = new VCardImpl();
    vcard.setVersion(new VersionType(VCardVersion.V3_0));
    vcard.setN(new NType("Doe", "John"));
    vcard.setFN(new FNType("John \"Johny\" Doe"));
    return vcard;
  }
View Full Code Here

    assertEquals(expected, encodedText);
  }
 
  @Test
  public void testForceEncodeQuotedPrintableSpaces_1() throws VCardBuildException {
    VCardImpl vcard = new VCardImpl();
    vcard.setVersion(new VersionType(VCardVersion.V3_0));
    vcard.setN(new NType("Doe", "John"));
    vcard.setFN(new FNType("John Doe"));
   
    NoteType note = new NoteType("This is a note with normal text.");
    note.setEncodingType(EncodingType.QUOTED_PRINTABLE);
    vcard.addNote(note);
   
    VCardWriter vcardWriter = new VCardWriter();
    vcardWriter.setOutputVersion(VCardVersion.V3_0);
    vcardWriter.setCompatibilityMode(CompatibilityMode.RFC2426);
    vcardWriter.setFoldingScheme(FoldingScheme.MIME_DIR);
View Full Code Here

    assertEquals(expectedVCard, resultVCard);
  }
 
  @Test
  public void testForceEncodeQuotedPrintableSpaces_2() throws VCardBuildException {
    VCardImpl vcard = new VCardImpl();
    vcard.setVersion(new VersionType(VCardVersion.V3_0));
    vcard.setN(new NType("Doe", "John"));
    vcard.setFN(new FNType("John Doe"));
   
    NoteType note = new NoteType("This is a note with normal text.");
    note.setEncodingType(EncodingType.QUOTED_PRINTABLE);
    vcard.addNote(note);
   
    VCardWriter vcardWriter = new VCardWriter();
    vcardWriter.setOutputVersion(VCardVersion.V3_0);
    vcardWriter.setCompatibilityMode(CompatibilityMode.RFC2426);
    vcardWriter.setFoldingScheme(FoldingScheme.MIME_DIR);
View Full Code Here

    assertEquals(expectedVCard, resultVCard);
  }
 
  @Test
  public void testForceEncodeQuotedPrintableSpaces_3() throws VCardBuildException {
    VCardImpl vcard = new VCardImpl();
    vcard.setVersion(new VersionType(VCardVersion.V3_0));
    vcard.setN(new NType("Doe", "John"));
    vcard.setFN(new FNType("John Doe"));
   
    NoteType note = new NoteType("新中西里杨阿姨 some spaces ");
    note.setEncodingType(EncodingType.QUOTED_PRINTABLE);
    vcard.addNote(note);
   
    VCardWriter vcardWriter = new VCardWriter();
    vcardWriter.setOutputVersion(VCardVersion.V3_0);
    vcardWriter.setCompatibilityMode(CompatibilityMode.RFC2426);
    vcardWriter.setFoldingScheme(FoldingScheme.MIME_DIR);
View Full Code Here

    assertEquals(expectedVCard, resultVCard);
  }
 
  @Test
  public void testForceEncodeQuotedPrintableSpaces_4() throws VCardBuildException {
    VCardImpl vcard = new VCardImpl();
    vcard.setVersion(new VersionType(VCardVersion.V3_0));
    vcard.setN(new NType("Doe", "John"));
    vcard.setFN(new FNType("John Doe"));
   
    NoteType note = new NoteType("新中西里杨阿姨 some spaces ");
    note.setEncodingType(EncodingType.QUOTED_PRINTABLE);
    vcard.addNote(note);
   
    VCardWriter vcardWriter = new VCardWriter();
    vcardWriter.setOutputVersion(VCardVersion.V3_0);
    vcardWriter.setCompatibilityMode(CompatibilityMode.RFC2426);
    vcardWriter.setFoldingScheme(FoldingScheme.MIME_DIR);
View Full Code Here

    sb.append("KEY;GPG;ENCODING=QUOTED-PRINTABLE:quoted printable=0D=0A=\r\n");
    sb.append(" key\r\n");
    sb.append("KEY;ENCODING=BASE64;X509:YmluYXJ5IGRhdGE=\r\n");
    sb.append("END:VCARD\r\n");

    VCardImpl vcard = (VCardImpl)vCardEngine.parse(sb.toString());

    List<KeyType> list = vcard.getKeys();

    KeyType f = list.get(0);
    assertEquals(KeyTextType.PGP, f.getKeyTextType());
    assertArrayEquals("plain text key".getBytes(), f.getKey());
    assertEquals(EncodingType.EIGHT_BIT, f.getEncodingType());
View Full Code Here

TOP

Related Classes of net.sourceforge.cardme.vcard.VCardImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.