Package net.sourceforge.cardme.vcard.types.params

Examples of net.sourceforge.cardme.vcard.types.params.ExtendedParamType


    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


      assertEquals("johnny5@aol.com", f.getExtendedValue());
     
      List<ExtendedParamType> xParamTypes = f.getExtendedParams();
      assertEquals(2, xParamTypes.size());
     
      ExtendedParamType xParamType = xParamTypes.get(0);
      assertEquals("TYPE", xParamType.getTypeName());
      assertEquals("HOME", xParamType.getTypeValue());
     
      xParamType = xParamTypes.get(1);
      assertEquals("X-COUCHDB-UUID",xParamType.getTypeName());
      assertEquals("cb9e11fc-bb97-4222-9cd8-99820c1de454".toUpperCase(), xParamType.getTypeValue());
     
      f = it.get(2);
      assertEquals("X-EVOLUTION-FILE-AS", f.getExtendedName());
      assertEquals("Doe, John", f.getExtendedValue());
     
View Full Code Here

          default:
          {
            if(val.indexOf(',') != -1) {
              String[] typeValueList = pt.getValue().split(",");
              for(String typeValue : typeValueList) {
                vcardType.addExtendedParam(new ExtendedParamType(nam, typeValue, VCardTypeName.XTENDED));
              }
            }
            else {
              vcardType.addExtendedParam(new ExtendedParamType(nam, val, VCardTypeName.XTENDED));
            }
           
            break;
          }
         
        }//switch type name
      }
      else if("VALUE".equalsIgnoreCase(nam)) {
        if("URI".equalsIgnoreCase(val)) {
          vcardType.setEncodingType(EncodingType.EIGHT_BIT);
        }
        else if("DATE".equalsIgnoreCase(val)) {
          switch(typeName)
          {
            case BDAY:
            {
              if(vcardType instanceof BDayFeature) {
                ((BDayFeature)vcardType).setParam(BDayParamType.DATE);
              }
             
              break;
            }
          }
        }
        else if("DATE-TIME".equalsIgnoreCase(val)) {
          switch(typeName)
          {
            case BDAY:
            {
              if(vcardType instanceof BDayFeature) {
                ((BDayFeature)vcardType).setParam(BDayParamType.DATE_TIME);
              }
             
              break;
            }
          }
        }
        else if("TEXT".equalsIgnoreCase(val)) {
          switch(typeName)
          {
            case TZ:
            {
              if(vcardType instanceof TzFeature) {
                ((TzType)vcardType).setParamType(TzParamType.TEXT);
              }
             
              break;
            }
          }
        }
        else if("UTC-OFFSET".equalsIgnoreCase(val)) {
          switch(typeName)
          {
            case TZ:
            {
              if(vcardType instanceof TzFeature) {
                ((TzType)vcardType).setParamType(TzParamType.UTC_OFFSET);
              }
             
              break;
            }
          }
        }
        else {
          throw new VCardParseException("Invalid value type \""+val+"\"");
        }
      }
      else {
        vcardType.addExtendedParam(new ExtendedParamType(nam, val, typeName));
      }
    }
  }
View Full Code Here

      String enumParamValue = paramValue.replace("-", "_").toUpperCase();
      AdrParamType paramType = AdrParamType.valueOf(enumParamValue);
      adrType.addParam(paramType);
    }
    catch(IllegalArgumentException iae) {
      ExtendedParamType xParamType = null;
      if(paramValue.indexOf('=') != -1) {
        String[] pTmp = paramValue.split("=");
        xParamType = new ExtendedParamType(pTmp[0], pTmp[1], VCardTypeName.ADR);
      }
      else {
        xParamType = new ExtendedParamType(paramValue, VCardTypeName.ADR);
      }
     
      adrType.addExtendedParam(xParamType);
    }
  }
View Full Code Here

    adrType.setPostOfficeBox("ABC567");
    adrType.setStreetAddress("25 Green Crecent Ave.");
    adrType.setExtendedAddress("Bla bla");
    adrType.addParam(AdrParamType.PREF)
      .addParam(AdrParamType.HOME)
      .addExtendedParam(new ExtendedParamType("X-OFFICE", VCardTypeName.ADR));
  }
View Full Code Here

      String enumParamValue = paramValue.replace("-", "_").toUpperCase();
      LabelParamType paramType = LabelParamType.valueOf(enumParamValue);
      labelType.addParam(paramType);
    }
    catch(IllegalArgumentException iae) {
      ExtendedParamType xParamType = null;
      if(paramValue.indexOf('=') != -1) {
        String[] pTmp = paramValue.split("=");
        xParamType = new ExtendedParamType(pTmp[0], pTmp[1], VCardTypeName.LABEL);
      }
      else {
        xParamType = new ExtendedParamType(paramValue, VCardTypeName.LABEL);
      }
     
      labelType.addExtendedParam(xParamType);
    }
  }
View Full Code Here

    assertTrue(adrType.hasParams());
  }
 
  @Test
  public void testContainsExtendedParam() {
    assertTrue(adrType.containsExtendedParam(new ExtendedParamType("X-OFFICE", VCardTypeName.ADR)));
    assertFalse(adrType.containsExtendedParam(new ExtendedParamType("X-NO-EXISTS", VCardTypeName.ADR)));
    assertFalse(adrType.containsExtendedParam(new ExtendedParamType("X-NO-EXISTS", VCardTypeName.TEL)));
  }
View Full Code Here

  }
 
  @Test
  public void testContainsAllExtendedParams() {
    List<ExtendedParamType> types = new ArrayList<ExtendedParamType>(1);
    types.add(new ExtendedParamType("X-OFFICE", VCardTypeName.ADR));
   
    assertTrue(adrType.containsAllExtendedParams(types));
  }
View Full Code Here

      String enumParamValue = paramValue.replace("-", "_").toUpperCase();
      TelParamType telParamType = TelParamType.valueOf(enumParamValue);
      telType.addParam(telParamType);
    }
    catch(IllegalArgumentException iae) {
      ExtendedParamType xParamType = null;
      if(paramValue.indexOf('=') != -1) {
        String[] pTmp = paramValue.split("=");
        xParamType = new ExtendedParamType(pTmp[0], pTmp[1], VCardTypeName.TEL);
      }
      else {
        xParamType = new ExtendedParamType(paramValue, VCardTypeName.TEL);
      }
     
      telType.addExtendedParam(xParamType);
    }
  }
View Full Code Here

    assertFalse(adrType.containsParam(AdrParamType.POSTAL));
  }
 
  @Test
  public void testRemoveExtendedParam() {
    adrType.addExtendedParam(new ExtendedParamType("X-REMOVEME", VCardTypeName.ADR));
    assertTrue(adrType.containsExtendedParam(new ExtendedParamType("X-REMOVEME", VCardTypeName.ADR)));
    adrType.removeExtendedParam(new ExtendedParamType("X-REMOVEME", VCardTypeName.ADR));
    assertFalse(adrType.containsExtendedParam(new ExtendedParamType("X-REMOVEME", VCardTypeName.ADR)));
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.cardme.vcard.types.params.ExtendedParamType

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.