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;