@Override public String getLanguage() { return super.getLanguage(); }
/** * Sets the binary data of the resource. * @param data the binary data * @param type the content type (e.g. "JPEG image") */ public void setData(byte[] data, T type) { this.url = null; this.data = data; setContentType(type); }
/** * Creates a binary property. * @param data the binary data * @param type the content type */ public BinaryProperty(byte[] data, T type) { setData(data, type); }
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 ""; }
@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); }
@Override public void setUrl(String url, KeyType type) { super.setUrl(url, type); text = null; }
@Override public void setLanguage(String language) { super.setLanguage(language); }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + ((text == null) ? 0 : text.hashCode()); return result; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; Key other = (Key) obj; if (text == null) { if (other.text != null) return false; } else if (!text.equals(other.text)) return false; return true; } }
/** * @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(); }
@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); if (property.getData() != null) { copy.setMediaType(null);
/** * Creates a binary property. * @param url the URL to the resource * @param type the content type */ public BinaryProperty(String url, T type) { setUrl(url, type); }
@Override public void setData(byte[] data, KeyType type) { super.setData(data, type); text = null; }
/** * Sets the URL to the resource. * @param url the URL * @param type the content type (e.g. "JPEG image") */ public void setUrl(String url, T type) { this.url = url; this.data = null; setContentType(type); }