Examples of ProdIdType


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

    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"));
View Full Code Here

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

    //VERSION
    assertEquals(VCardVersion.V3_0, vcard.getVersion().getVersion());
   
    //PRODID
    {
      ProdIdType f = vcard.getProdId();
      assertEquals("-//Apple Inc.//iOS 5.0.1//EN", f.getProdId());
    }
   
    //N
    {
      NType f = vcard.getN();
      assertEquals("Doe", f.getFamilyName());
      assertEquals("John", f.getGivenName());
     
      List<String> it = f.getAdditionalNames();
      assertEquals(2, it.size());
      assertEquals("Richter", it.get(0));
      assertEquals("James", it.get(1));
     
      it = f.getHonorificPrefixes();
      assertEquals(1, it.size());
      assertEquals("Mr.", it.get(0));
     
      it = f.getHonorificSuffixes();
      assertEquals(1, it.size());
      assertEquals("Sr.", it.get(0));
    }
   
    //FN
    {
      FNType f = vcard.getFN();
      assertEquals("Mr. John Richter James Doe Sr.", f.getFormattedName());
    }
   
    //NICKNAME
    {
      NicknameType f = vcard.getNicknames();
      List<String> it = f.getNicknames();
      assertEquals("Johny", it.get(0));
    }
   
    //ORG
    {
      OrgType f = vcard.getOrg();
      assertEquals("IBM", f.getOrgName());
     
      List<String> it = f.getOrgUnits();
      assertEquals(1, it.size());
      assertEquals("Accounting", it.get(0));
    }
   
    //TITLE
    {
      TitleType f = vcard.getTitle();
      assertEquals("Money Counter", f.getTitle());
    }
   
    //EMAIL
    {
      List<EmailType> it = vcard.getEmails();
      assertEquals(1, it.size());
     
      EmailType f = it.get(0);
      assertEquals("item1", f.getGroup());
      assertEquals("john.doe@ibm.com", f.getEmail());
     
      List<EmailParamType> types = f.getParams();
      assertEquals(2, types.size());
      assertTrue(types.contains(EmailParamType.INTERNET));
      assertTrue(types.contains(EmailParamType.PREF));
    }
   
    //TEL
    {
      List<TelType> it = vcard.getTels();
      assertEquals(7, it.size());
     
      TelType f = it.get(0);
      assertEquals("905-555-1234", f.getTelephone());
      List<TelParamType> paramsTypes = f.getParams();
      assertEquals(3, paramsTypes.size());
      assertTrue(paramsTypes.contains(TelParamType.CELL));
      assertTrue(paramsTypes.contains(TelParamType.VOICE));
      assertTrue(paramsTypes.contains(TelParamType.PREF));

      f = it.get(1);
      assertEquals("905-666-1234", f.getTelephone());
      paramsTypes = f.getParams();
      assertEquals(2, paramsTypes.size());
      assertTrue(paramsTypes.contains(TelParamType.HOME));
      assertTrue(paramsTypes.contains(TelParamType.VOICE));
     
      f = it.get(2);
      assertEquals("905-777-1234", f.getTelephone());
      paramsTypes = f.getParams();
      assertEquals(2, paramsTypes.size());
      assertTrue(paramsTypes.contains(TelParamType.WORK));
      assertTrue(paramsTypes.contains(TelParamType.VOICE));
     
      f = it.get(3);
      assertEquals("905-888-1234", f.getTelephone());
      paramsTypes = f.getParams();
      assertEquals(2, paramsTypes.size());
      assertTrue(paramsTypes.contains(TelParamType.HOME));
      assertTrue(paramsTypes.contains(TelParamType.FAX));
       
      f = it.get(4);
      assertEquals("905-999-1234", f.getTelephone());
      paramsTypes = f.getParams();
      assertEquals(2, paramsTypes.size());
      assertTrue(paramsTypes.contains(TelParamType.WORK));
      assertTrue(paramsTypes.contains(TelParamType.FAX));
     
      f = it.get(5);
      assertEquals("905-111-1234", f.getTelephone());
      paramsTypes = f.getParams();
      assertEquals(1, paramsTypes.size());
      assertTrue(paramsTypes.contains(TelParamType.PAGER));
     
      f = it.get(6);
      assertEquals("905-222-1234", f.getTelephone());
      assertEquals("item2", f.getGroup());
      paramsTypes = f.getParams();
      assertEquals(0, paramsTypes.size());
    }
   
    //ADR
    {
      List<AdrType> it = vcard.getAdrs();
      assertEquals(2, it.size());
     
      AdrType f = it.get(0);
      assertEquals("item3", f.getGroup());
      assertEquals("", f.getPostOfficeBox());
      assertEquals("", f.getExtendedAddress());
      assertEquals("Silicon Alley 5,", f.getStreetAddress());
      assertEquals("New York", f.getLocality());
      assertEquals("New York", f.getRegion());
      assertEquals("12345", f.getPostalCode());
      assertEquals("United States of America", f.getCountryName());
     
      List<AdrParamType> paramTypes = f.getParams();
      assertEquals(2, paramTypes.size());
      assertTrue(paramTypes.contains(AdrParamType.HOME));
      assertTrue(paramTypes.contains(AdrParamType.PREF));
     
      f = it.get(1);
      assertEquals("item4", f.getGroup());
      assertEquals("", f.getPostOfficeBox());
      assertEquals("", f.getExtendedAddress());
      assertEquals("Street4\nBuilding 6\nFloor 8", f.getStreetAddress());
      assertEquals("New York", f.getLocality());
      assertEquals("", f.getRegion());
      assertEquals("12345", f.getPostalCode());
      assertEquals("USA", f.getCountryName());
     
      paramTypes = f.getParams();
      assertEquals(1, paramTypes.size());
      assertTrue(paramTypes.contains(AdrParamType.WORK));
    }
   
    //URL
    {
      List<UrlType> it = vcard.getUrls();
      assertEquals(1, it.size());
     
      UrlType f = it.get(0);
      assertEquals("item5", f.getGroup());
      assertEquals("http://www.ibm.com", f.getRawUrl());
     
      List<UrlParamType> types = f.getParams();
      assertEquals(1, types.size());
      assertTrue(types.contains(UrlParamType.PREF));
    }
   
    //BDAY
    {
      BDayType f = vcard.getBDay();
      assertEquals(2012, f.getBirthday().get(Calendar.YEAR));
      assertEquals(Calendar.JUNE, f.getBirthday().get(Calendar.MONTH));
      assertEquals(6, f.getBirthday().get(Calendar.DAY_OF_MONTH));
      assertEquals(ISOFormat.ISO8601_DATE_EXTENDED, f.getISO8601Format());
    }
   
    //PHOTO
    {
      List<PhotoType> it = vcard.getPhotos();
      assertEquals(1, it.size());
     
      PhotoType f = it.get(0);
      assertEquals(EncodingType.BINARY, f.getEncodingType());
      assertEquals(ImageMediaType.JPEG, f.getImageMediaType());
      assertEquals(32531, f.getPhoto().length);
    }
   
    //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("_$!<AssistantPhone>!$_", f.getExtendedValue());

      f = it.get(1);
      assertEquals("item3", f.getGroup());
      assertEquals("X-ABADR", f.getExtendedName());
      assertEquals("Silicon Alley", f.getExtendedValue());
     
      f = it.get(2);
      assertEquals("item4", f.getGroup());
      assertEquals("X-ABADR", f.getExtendedName());
      assertEquals("Street 4, Building 6,\n Floor 8\nNew York\nUSA", f.getExtendedValue());
     
      f = it.get(3);
      assertEquals("item5", f.getGroup());
      assertEquals("X-ABLABEL", f.getExtendedName());
      assertEquals("_$!<HomePage>!$_", f.getExtendedValue());
    }
   
    VCardImpl vcard2 = (VCardImpl)vcard;
   
    if(vcard2.hasErrors()) {
View Full Code Here

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

    //VERSION
    assertEquals(VCardVersion.V3_0, vcard.getVersion().getVersion());
   
    //PRODID
    {
      ProdIdType f = vcard.getProdId();
      assertEquals("-//Apple Inc.//Address Book 6.1//EN", f.getProdId());
    }
   
    //N
    {
      NType f = vcard.getN();
      assertEquals("Doe", f.getFamilyName());
      assertEquals("John", f.getGivenName());
     
      List<String> it = f.getAdditionalNames();
      assertEquals(1, it.size());
      assertEquals("Johny", it.get(0));
     
      it = f.getHonorificPrefixes();
      assertEquals(1, it.size());
      assertEquals("Mr.", it.get(0));
     
      it = f.getHonorificSuffixes();
      assertEquals(1, it.size());
      assertEquals("I", it.get(0));
    }
   
    //FN
    {
      FNType f = vcard.getFN();
      assertEquals("Mr. Doe John I Johny", f.getFormattedName());
    }
   
    //NICKNAME
    {
      NicknameType f = vcard.getNicknames();
      List<String> it = f.getNicknames();
      assertEquals(1, it.size());
      assertEquals("Johny,JayJay", it.get(0));
    }
   
    //ORG
    {
      OrgType f = vcard.getOrg();
      assertEquals("IBM", f.getOrgName());
     
      List<String> it = f.getOrgUnits();
      assertEquals(1, it.size());
      assertEquals("SUN", it.get(0));
    }
   
    //TITLE
    {
      TitleType f = vcard.getTitle();
      assertEquals("Generic Accountant", f.getTitle());
    }
   
    //EMAIL
    {
      List<EmailType> it = vcard.getEmails();
      assertEquals(2, it.size());
     
      EmailType f = it.get(0);
      assertEquals("john.doe@ibm.com", f.getEmail());
     
      List<EmailParamType> types = f.getParams();
      assertEquals(3, types.size());
      assertTrue(types.contains(EmailParamType.INTERNET));
      assertTrue(types.contains(EmailParamType.WORK));
      assertTrue(types.contains(EmailParamType.PREF));
     
      f = it.get(1);
      assertEquals("billy_bob@gmail.com", f.getEmail());
      types = f.getParams();
      assertEquals(2, types.size());
      assertTrue(types.contains(EmailParamType.INTERNET));
      assertTrue(types.contains(EmailParamType.WORK));
    }
   
    //TEL
    {
      List<TelType> it = vcard.getTels();
      assertEquals(2, it.size());
     
      TelType f = it.get(0);
      assertEquals("+1 (212) 204-34456", f.getTelephone());
      List<TelParamType> types = f.getParams();
      assertEquals(3, types.size());
      assertTrue(types.contains(TelParamType.CELL));
      assertTrue(types.contains(TelParamType.VOICE));
      assertTrue(types.contains(TelParamType.PREF));

      f = it.get(1);
      assertEquals("00-1-212-555-7777", f.getTelephone());
      types = f.getParams();
      assertEquals(2, types.size());
      assertTrue(types.contains(TelParamType.WORK));
      assertTrue(types.contains(TelParamType.FAX));
    }
   
    //ADR
    {
      List<AdrType> it = vcard.getAdrs();
      assertEquals(1, it.size());
     
      AdrType f = it.get(0);
      assertEquals("item1", f.getGroup());
      assertEquals("", f.getPostOfficeBox());
      assertEquals("", f.getExtendedAddress());
      assertEquals("25334\nSouth cresent drive, Building 5, 3rd floo r", f.getStreetAddress());
      assertEquals("New York", f.getLocality());
      assertEquals("New York", f.getRegion());
      assertEquals("NYC887", f.getPostalCode());
      assertEquals("U.S.A.", f.getCountryName());
     
      List<AdrParamType> types = f.getParams();
      assertEquals(2, types.size());
      assertTrue(types.contains(AdrParamType.HOME));
      assertTrue(types.contains(AdrParamType.PREF));
    }
   
    //NOTE
    {
      List<NoteType> it = vcard.getNotes();
      assertEquals(1, it.size());
      NoteType f = it.get(0);
      assertEquals("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 P URPOSE\nARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTOR S BE\nLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS \nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nA RISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n POSSIBILITY OF SUCH DAMAGE.", f.getNote());
    }
   
    //URL
    {
      List<UrlType> it = vcard.getUrls();
      assertEquals(1, it.size());
     
      UrlType f = it.get(0);
      assertEquals("item2", f.getGroup());
      assertEquals("http://www.sun.com", f.getRawUrl());
     
      List<UrlParamType> types = f.getParams();
      assertEquals(1, types.size());
      assertTrue(types.contains(UrlParamType.PREF));
    }
   
    //BDAY
    {
      BDayType f = vcard.getBDay();
      assertEquals(1980, f.getBirthday().get(Calendar.YEAR));
      assertEquals(Calendar.MAY, f.getBirthday().get(Calendar.MONTH));
      assertEquals(21, f.getBirthday().get(Calendar.DAY_OF_MONTH));
      assertEquals(ISOFormat.ISO8601_DATE_EXTENDED, f.getISO8601Format());
    }
   
    //PHOTO
    {
      List<PhotoType> it = vcard.getPhotos();
      assertEquals(1, it.size());
     
      PhotoType f = it.get(0);
      assertEquals(EncodingType.BINARY, f.getEncodingType());
      assertEquals(ImageMediaType.JPEG, f.getImageMediaType());
      assertEquals(7957, f.getPhoto().length);
    }
   
    //UID
    {
      UidType f = vcard.getUid();
      assertEquals("0e7602cc-443e-4b82-b4b1-90f62f99a199", f.getUid());
    }
   
    //GEO
    {
      GeoType f = vcard.getGeo();
      assertEquals(-2.6, f.getLatitude(), .01);
      assertEquals(3.4, f.getLongitude(), .01);
    }
   
    //CLASS
    {
      ClassType f = vcard.getSecurityClass();
      assertEquals("Public", f.getSecurityClass());
    }
   
    //PROFILE
    {
      ProfileType f = vcard.getProfile();
      assertEquals("VCard", f.getProfile());
    }
   
    //TZ
    {
      TzType f = vcard.getTz();
      assertEquals(1, f.getHourOffset());
      assertEquals(0, f.getMinuteOffset());
    }
   
    //LABEL
    {
      //This label does not get parsed because its parameter types
      //do not match any of the parameter types of any of the existing
      //addresses. In this case the parameter type PARCEL is extra from
      //the address.
      //
      //This is an issue with the way Labels and Addresses are defined in
      //the VCard RFC. There are 2 ways to go about it:
      //
      //1: An ADR may have only 1 LABEL associated to it, the LABEL directly under it
      //2: An ADR may have only 1 LABEL associated to it by parameter types. Only
      //   one ADR and LABEL without zero parameter types may hold an association.
      //
      // Cardme takes approach 2.
     
      /*
      List<LabelType> it = vcard.getLables();
      assertEquals(1, it.size());
     
      LabelType f = it.get(0);
      assertEquals("John Doe\nNew York, NewYork,\nSouth Crecent Drive,\nBuilding 5, floor 3,\nUSA", f.getLabel());
      List<LabelParamType> types = f.getParams();
      assertEquals(3, types.size());
      assertTrue(types.contains(LabelParamType.HOME));
      assertTrue(types.contains(LabelParamType.PARCEL));
      assertTrue(types.contains(LabelParamType.PREF));
      */
     
    }
   
    //SORT-STRING
    {
      SortStringFeature f = vcard.getSortString();
      assertEquals("JOHN", f.getSortString());
    }
   
    //ROLE
    {
      RoleFeature f = vcard.getRole();
      assertEquals("Counting Money", f.getRole());
    }
   
    //SOURCE
    {
      SourceFeature f = vcard.getSource();
      assertEquals("Whatever", f.getSource());
    }
   
    //MAILER
    {
      MailerFeature f = vcard.getMailer();
      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

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

   * @param vcard
   * @throws VCardParseException
   */
  private void parseProdIdType(String group, String value, List<ParameterType> paramTypeList, VCardImpl vcard) throws VCardParseException {
    try {
      ProdIdType prodIdType = new ProdIdType();
      parseParamTypes(prodIdType, paramTypeList, value, VCardTypeName.PRODID);
     
      if(prodIdType.isQuotedPrintable()) {
        value = decodeQuotedPrintableValue(prodIdType, value);
      }
     
      if(group != null) {
        prodIdType.setGroup(group);
      }
     
      prodIdType.setProdId(VCardUtils.unescapeString(value));
      vcard.setProdId(prodIdType);
    }
    catch(Exception ex) {
      throw new VCardParseException("ProdIdType ("+VCardTypeName.PRODID.getType()+") ["+ex.getClass().getName()+"] "+ex.getMessage(), ex);
    }
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.