@Override protected void _prepareParameters( T property, VCardParameters copy, VCardVersion version, VCard vcard) { MediaTypeParameter contentType = property.getContentType(); if (contentType == null) { contentType = new MediaTypeParameter(null, null, null); } if (property.getUrl() != null) { copy.setEncoding(null); switch (version) { case V2_1: copy.setType(contentType.getValue()); copy.setMediaType(null); break; case V3_0: copy.setType(contentType.getValue()); copy.setMediaType(null); break; case V4_0: copy.setMediaType(contentType.getMediaType()); break; } return; } if (property.getData() != null) { copy.setMediaType(null); switch (version) { case V2_1: copy.setEncoding(Encoding.BASE64); copy.setType(contentType.getValue()); break; case V3_0: copy.setEncoding(Encoding.B); copy.setType(contentType.getValue()); break; case V4_0: copy.setEncoding(null); // don't null out TYPE, it could be set to "home", "work", etc break; } return; } }
private String write(T property, VCardVersion version) { String url = property.getUrl(); if (url != null) { return url; } byte data[] = property.getData(); if (data != null) { switch (version) { case V2_1: case V3_0: return new String(Base64.encodeBase64(data)); case V4_0: U contentType = property.getContentType(); String mediaType = (contentType == null || contentType.getMediaType() == null) ? "application/octet-stream" : contentType.getMediaType(); return new DataUri(mediaType, data).toString(); } } return ""; }