Package net.sourceforge.cardme.vcard.types

Examples of net.sourceforge.cardme.vcard.types.NameType


    /* This string will work just fine as the fold is in the middle of a word */
    final String correctNote = "Lines seem to be unfolded correctly if spaces aren't exactly on a folding boundary.";
   
    VCard vcard = new VCardImpl();
    vcard.setVersion(new VersionType(VCardVersion.V3_0));
    vcard.setName(new NameType("Some Name"));
    vcard.addNote(new NoteType(correctNote));

    VCardWriter writer = new VCardWriter();
    writer.setVCard(vcard);
    String vcardString = writer.buildVCardString();
   
    VCardEngine vcardEngine = new VCardEngine(CompatibilityMode.RFC2426);
    VCard parsedVcard = vcardEngine.parse(vcardString);
   
    assertNotNull(parsedVcard);
    assertTrue(parsedVcard.hasNotes());
    assertTrue(parsedVcard.getNotes().size() == 1);

    String parsedNote = parsedVcard.getNotes().get(0).getNote();
    assertEquals(correctNote, parsedNote);
   
    //------------------------------------------------------
   
    /* This string has the fold right at a space and the space is lost when retrieving it later */
    final String incorrectNote = "Lines seem to be unfolded incorrectly if spaces are just exactly on a folding boundary.";
   
    vcard = new VCardImpl();
    vcard.setVersion(new VersionType(VCardVersion.V3_0));
    vcard.setName(new NameType("Some Name"));
    vcard.addNote(new NoteType(incorrectNote));

    writer = new VCardWriter();
    writer.setVCard(vcard);
    vcardString = writer.buildVCardString();
View Full Code Here


  private static VCardImpl getFullVCardNoErrors() throws IOException, URISyntaxException
  {
    VCardImpl vcard = new VCardImpl();
    vcard.setVersion(new VersionType(VCardVersion.V3_0));
   
    NameType name = new NameType();
    name.setName("VCard for John Doe");
    vcard.setName(name);
   
    ProfileType profile = new ProfileType();
    profile.setProfile("VCard");
    vcard.setProfile(profile);
View Full Code Here

  }
 
  @Test
  public void testBuildNameType() throws VCardBuildException {
    VCardImpl vcard = getSimpleVCard();
    vcard.setName(new NameType("VCard for John Doe"));
   
    VCardWriter vcardWriter = new VCardWriter();
    vcardWriter.setOutputVersion(VCardVersion.V3_0);
    vcardWriter.setCompatibilityMode(CompatibilityMode.RFC2426);
    vcardWriter.setFoldingScheme(FoldingScheme.MIME_DIR);
View Full Code Here

   * @param vcard
   * @throws VCardParseException
   */
  private void parseNameType(String group, String value, List<ParameterType> paramTypeList, VCardImpl vcard) throws VCardParseException {
    try {
      NameType nameType = new NameType();
      parseParamTypes(nameType, paramTypeList, value, VCardTypeName.NAME);
     
      if(nameType.isQuotedPrintable()) {
        value = decodeQuotedPrintableValue(nameType, value);
      }
     
      if(group != null) {
        nameType.setGroup(group);
      }
     
      nameType.setName(VCardUtils.unescapeString(value));
      vcard.setName(nameType);
    }
    catch(Exception ex) {
      throw new VCardParseException("NameType ("+VCardTypeName.NAME.getType()+") ["+ex.getClass().getName()+"] "+ex.getMessage(), ex);
    }
View Full Code Here

      assertEquals("Mozilla Thunderbird", f.getMailer());
    }
   
    //NAME
    {
      NameType f = vcard.getName();
      assertEquals("VCard for John Doe", f.getName());
    }
   
    //custom types
    {
      List<ExtendedType> it = vcard.getExtendedTypes();
      assertEquals(4, it.size());
     
      ExtendedType f = it.get(0);
      assertEquals("item2", f.getGroup());
      assertEquals("X-ABLABEL", f.getExtendedName());
      assertEquals("_$!<HomePage>!$_", f.getExtendedValue());

      f = it.get(1);
      assertEquals("X-ABUID", f.getExtendedName());
      assertEquals("0E7602CC-443E-4B82-B4B1-90F62F99A199:ABPerson", f.getExtendedValue());
     
      f = it.get(2);
      assertEquals("X-GENERATOR", f.getExtendedName());
      assertEquals("Cardme Generator", f.getExtendedValue());
     
      f = it.get(3);
      assertEquals("X-LONG-STRING", f.getExtendedName());
      assertEquals("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", f.getExtendedValue());
    }
   
    VCardImpl vcard2 = (VCardImpl)vcard;
   
    if(vcard2.hasErrors()) {
View Full Code Here

TOP

Related Classes of net.sourceforge.cardme.vcard.types.NameType

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.