Examples of VCardImpl


Examples of info.ineighborhood.cardme.impl.VCardImpl

   * @return the VCard
   */
  public String createVCard(IContact contact, List<VCardContactField> vcards) {
    String vcardMapping = "";
    String attributeValue = "";
    info.ineighborhood.cardme.VCard vcard = new VCardImpl();
    VCardAddress vcardAddress = new VCardAddress();
    try {
      vcard.setVersion(info.ineighborhood.cardme.VCard.VERSION_3_0);
      vcard.setRevisionDate(Calendar.getInstance());
      vcard.setTimeZone(Calendar.getInstance().getTimeZone());
      for (int i = 0; i < vcards.size(); i++) {
        attributeValue = "";
        VCardContactField card = vcards.get(i);
        String profileAttribute = card.getProfileAttribute().trim();
        if(card.isEnabled()) {
          attributeValue = this.getVcardFieldValue(contact, profileAttribute);
        }
        String code = card.getCode().trim();
        this.setVcardFields(attributeValue, code, vcard, vcardAddress);
      }
      vcard.addAddress(this.createAddress(vcardAddress, MailingAddressType.HOME_MAILING_ADDRESS));
      vcardMapping = vcard.toString();
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "createVCard");
    }
    return vcardMapping;
  }
View Full Code Here

Examples of net.sourceforge.cardme.vcard.VCardImpl

  private static VCardImpl vcard = null;
  private static VCardImpl vcardFull = null;
 
  @BeforeClass
  public static void setUpBeforeClass() throws Exception {
    vcard = new VCardImpl();
    vcardFull = getFullVCardNoErrors();
  }
View Full Code Here

Examples of net.sourceforge.cardme.vcard.VCardImpl

  public void testUnfoldingSpaceBug() throws VCardBuildException, IOException, VCardParseException {
   
    /* 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

Examples of net.sourceforge.cardme.vcard.VCardImpl

    assertEquals(incorrectNote, parsedNote);
  }
 
  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);
   
    SourceType source = new SourceType();
    source.setSource("Whatever");
    vcard.setSource(source);
   
    NType n = new NType();
    n.setEncodingType(EncodingType.QUOTED_PRINTABLE);
    n.setCharset(Charset.forName("UTF-8"));
    n.setLanguage(LanguageType.EN);
    n.setFamilyName("DÖe");
//    n.setFamilyName("Doe");
    n.setGivenName("John");
    n.addHonorificPrefix("Mr.");
    n.addHonorificSuffix("I");
    n.addAdditionalName("Johny");
    vcard.setN(n);
   
    FNType fn = new FNType();
    fn.setFormattedName("John \"Johny\" Doe");
    fn.setCharset(Charset.forName("UTF-8"));
    fn.setLanguage(LanguageType.EN);
    vcard.setFN(fn);
   
    NicknameType nicknames = new NicknameType();
    nicknames.addNickname("Johny");
    nicknames.addNickname("JayJay");
    vcard.setNickname(nicknames);
   
    CategoriesType categories = new CategoriesType();
    categories.addCategory("Category 1");
    categories.addCategory("Category 2");
    categories.addCategory("Category 3");
    vcard.setCategories(categories);
   
    vcard.setSecurityClass(new ClassType("Public"));
    vcard.setProdId(new ProdIdType("31e78c0d-fb07-479d-b6af-95a9a3f2916f"));
    vcard.setSortString(new SortStringType("JOHN"));
   
    vcard.setMailer(new MailerType("Mozilla Thunderbird"));
    vcard.setTitle(new TitleType("Generic Accountant"));
    vcard.setRole(new RoleType("Counting Money"));
   
    OrgType organizations = new OrgType();
    organizations.setOrgName("IBM");
    organizations.addOrgUnit("SUN");
    vcard.setOrg(organizations);
   
    vcard.setUid(new UidType("c0ff639f-9633-4e57-bcfd-55079cfd9d65"));
    vcard.addUrl(new UrlType(new URL("http://www.sun.com")));
    vcard.setGeo(new GeoType(3.4f, -2.6f));

    Calendar birthday = Calendar.getInstance();
    birthday.clear();
    birthday.set(Calendar.YEAR, 1980);
    birthday.set(Calendar.MONTH, 4);
    birthday.set(Calendar.DAY_OF_MONTH, 21);
    vcard.setBDay(new BDayType(birthday));

    Calendar revision = Calendar.getInstance();
    revision.clear();
    revision.set(Calendar.YEAR, 2012);
    revision.set(Calendar.MONTH, 6);
    revision.set(Calendar.DAY_OF_MONTH, 8);
    vcard.setRev(new RevType(revision));
   
    vcard.setTz(new TzType(Calendar.getInstance().getTimeZone()));
   
    AdrType address1 = new AdrType();
    address1.setCharset("UTF-8");
    address1.setExtendedAddress("");
    address1.setCountryName("U.S.A.");
    address1.setLocality("New York");
    address1.setRegion("New York");
    address1.setPostalCode("NYC887");
    address1.setPostOfficeBox("25334");
    address1.setStreetAddress("South cresent drive, Building 5, 3rd floor");
    address1.addParam(AdrParamType.HOME)
    .addParam(AdrParamType.PARCEL)
    .addParam(AdrParamType.PREF)
    .addExtendedParam(new ExtendedParamType("CUSTOM-PARAM-TYPE", VCardTypeName.ADR))
    .addExtendedParam(new ExtendedParamType("CUSTOM-PARAM-TYPE", "WITH-CUSTOM-VALUE", VCardTypeName.ADR));
   

    LabelType labelForAddress1 = new LabelType();
    labelForAddress1.setCharset("UTF-8");
    labelForAddress1.addParam(LabelParamType.HOME)
    .addParam(LabelParamType.PARCEL)
    .addParam(LabelParamType.PREF)
    .setLabel("John Doe\nNew York, NewYork,\nSouth Crecent Drive,\nBuilding 5, floor 3,\nUSA");
   
    address1.setLabel(labelForAddress1);
    vcard.addAdr(address1);
   
    TelType telephone = new TelType();
    telephone.setCharset("UTF-8");
    telephone.setTelephone("+1 (212) 204-34456");
    telephone.addParam(TelParamType.CELL)
    .addParam(TelParamType.HOME)
    .setParameterTypeStyle(ParameterTypeStyle.PARAMETER_VALUE_LIST);
    vcard.addTel(telephone);
   
    TelType telephone2 = new TelType();
    telephone2.setTelephone("00-1-212-555-7777");
    telephone2.addParam(TelParamType.FAX)
    .addParam(TelParamType.WORK)
    .setParameterTypeStyle(ParameterTypeStyle.PARAMETER_LIST);
    vcard.addTel(telephone2);
   
    EmailType email = new EmailType();
    email.setEmail("john.doe@ibm.com");
    email.addParam(EmailParamType.IBMMAIL)
    .addParam(EmailParamType.INTERNET)
    .addParam(EmailParamType.PREF)
    .setCharset("UTF-8");
    vcard.addEmail(email);
    vcard.addEmail(new EmailType("billy_bob@gmail.com"));
   
    NoteType note = new NoteType();
    note.setNote("THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\nLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.");
    vcard.addNote(note);
   
    PhotoType photo1 = new PhotoType();
    photo1.setCompression(false);
    photo1.setEncodingType(EncodingType.BINARY);
    photo1.setImageMediaType(ImageMediaType.PNG);
    byte[] tuxPicture1 = Util.getFileAsBytes(new File("test/images/smallTux.png"));
    photo1.setPhoto(tuxPicture1);
    vcard.addPhoto(photo1);
   
    LogoType logo = new LogoType();
    logo.setCompression(true);
    logo.setEncodingType(EncodingType.BINARY);
    logo.setImageMediaType(ImageMediaType.PNG);
    byte[] tuxPicture2 = Util.getFileAsBytes(new File("test/images/smallTux.png"));
    logo.setLogo(tuxPicture2);
    vcard.addLogo(logo);
   
    SoundType sound = new SoundType();
    sound.setCompression(false);
    sound.setEncodingType(EncodingType.BINARY);
    sound.setAudioMediaType(AudioMediaType.OGG);
    sound.setSoundURI(new File("test/images/smallTux.png").toURI());
    vcard.addSound(sound);
   
    KeyType key = new KeyType();
    key.setKeyTextType(KeyTextType.GPG);
    key.setEncodingType(EncodingType.BINARY);
    key.setCompression(false);
    byte[] keyBytes = Util.getFileAsBytes(new File("test/images/smallTux.png"));
    key.setKey(keyBytes);
    vcard.addKey(key);
   
    ExtendedType xGenerator = new ExtendedType("X-GENERATOR", "Cardme Generator");
    xGenerator.setCharset("UTF-8");
   
    vcard.addExtendedType(xGenerator);
    vcard.addExtendedType(new ExtendedType("X-LONG-STRING", "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"));
   
    vcard.addImpp(new ImppType("im:alice@example.com"));
    vcard.addImpp(new ImppType(new URI("im:alice2@example.com")));
   
    ImppType impp = new ImppType();
    impp.setUri(new URI("im:alice3@example.com"));
    impp.addParam(ImppParamType.HOME)
    .addParam(ImppParamType.PREF)
    .addExtendedParam(new ExtendedParamType("X-BLA", "BLE", VCardTypeName.IMPP));
    vcard.addImpp(impp);
   
    ((VCardErrorHandler)vcard).setThrowExceptions(false);
   
    return vcard;
  }
View Full Code Here

Examples of net.sourceforge.cardme.vcard.VCardImpl

*/
public class VCardWriterTest {

  @Test
  public void testBuildBeginType() throws VCardBuildException {
    VCardImpl vcard = getSimpleVCard();
    VCardWriter vcardWriter = new VCardWriter();
    vcardWriter.setOutputVersion(VCardVersion.V3_0);
    vcardWriter.setCompatibilityMode(CompatibilityMode.RFC2426);
    vcardWriter.setFoldingScheme(FoldingScheme.MIME_DIR);
    vcardWriter.setVCard(vcard);
View Full Code Here

Examples of net.sourceforge.cardme.vcard.VCardImpl

    assertTrue(vcardStr.contains("BEGIN:VCARD\r\n"));
  }
 
  @Test
  public void testBuildEndType() throws VCardBuildException {
    VCardImpl vcard = getSimpleVCard();
   
    VCardWriter vcardWriter = new VCardWriter();
    vcardWriter.setOutputVersion(VCardVersion.V3_0);
    vcardWriter.setCompatibilityMode(CompatibilityMode.RFC2426);
    vcardWriter.setFoldingScheme(FoldingScheme.MIME_DIR);
View Full Code Here

Examples of net.sourceforge.cardme.vcard.VCardImpl

    assertTrue(vcardStr.contains("END:VCARD\r\n"));
  }
 
  @Test
  public void testBuildVersionType() throws VCardBuildException {
    VCardImpl vcard = getSimpleVCard();
    vcard.setVersion(new VersionType(VCardVersion.V3_0));
   
    VCardWriter vcardWriter = new VCardWriter();
    vcardWriter.setOutputVersion(VCardVersion.V3_0);
    vcardWriter.setCompatibilityMode(CompatibilityMode.RFC2426);
    vcardWriter.setFoldingScheme(FoldingScheme.MIME_DIR);
View Full Code Here

Examples of net.sourceforge.cardme.vcard.VCardImpl

    assertTrue(vcardStr.contains("VERSION:3.0\r\n"));
  }
 
  @Test
  public void testBuildNType() throws VCardBuildException {
    VCardImpl vcard = getSimpleVCard();
    NType n = new NType();
    n.setFamilyName("Doe");
    n.setGivenName("John");
    n.addAdditionalName("Johny");
    n.addHonorificPrefix("Mr.");
    n.addHonorificSuffix("I");
    vcard.setN(n);
   
    VCardWriter vcardWriter = new VCardWriter();
    vcardWriter.setOutputVersion(VCardVersion.V3_0);
    vcardWriter.setCompatibilityMode(CompatibilityMode.RFC2426);
    vcardWriter.setFoldingScheme(FoldingScheme.MIME_DIR);
View Full Code Here

Examples of net.sourceforge.cardme.vcard.VCardImpl

    assertTrue(vcardStr.contains("N:Doe;John;Johny;Mr.;I\r\n"));
  }
 
  @Test
  public void testBuildFNType() throws VCardBuildException {
    VCardImpl vcard = getSimpleVCard();
    FNType fn = new FNType("John \"Johny\" Doe");
    fn.setLanguage(LanguageType.EN);
    vcard.setFN(fn);
   
    VCardWriter vcardWriter = new VCardWriter();
    vcardWriter.setOutputVersion(VCardVersion.V3_0);
    vcardWriter.setCompatibilityMode(CompatibilityMode.RFC2426);
    vcardWriter.setFoldingScheme(FoldingScheme.MIME_DIR);
View Full Code Here

Examples of net.sourceforge.cardme.vcard.VCardImpl

    assertTrue(vcardStr.contains("FN;LANGUAGE=en:John \"Johny\" Doe\r\n"));
  }
 
  @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
TOP
Copyright © 2018 www.massapi.com. 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.