@Override protected VCardDataType _dataType(T property, VCardVersion version) { if (property.getUrl() != null) { switch (version) { case V2_1: return VCardDataType.URL; case V3_0: case V4_0: return VCardDataType.URI; } } if (property.getData() != null) { switch (version) { case V2_1: case V3_0: return null; case V4_0: return VCardDataType.URI; } } return _defaultDataType(version); }
/** * @see TargetApplication#OUTLOOK */ private void fixBinaryPropertyForOutlook(VCardProperty property) throws IOException { if (targetApplication != TargetApplication.OUTLOOK) { return; } if (getTargetVersion() == VCardVersion.V4_0) { //only do this for 2.1 and 3.0 vCards return; } if (!(property instanceof BinaryProperty)) { //property does not have binary data return; } BinaryProperty<?> binaryProperty = (BinaryProperty<?>) property; if (binaryProperty.getData() == null) { //property value is not base64-encoded return; } writer.getFoldedLineWriter().writeln(); }
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 Base64.encodeBase64String(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 ""; }
if (property.getData() != null) { copy.setMediaType(null);