|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectezvcard.property.VCardProperty
ezvcard.property.BinaryProperty<ImageType>
ezvcard.property.ImageProperty
ezvcard.property.Logo
public class Logo
A company logo.
Adding a logo
VCard vcard = new VCard(); //URL Logo logo = new Logo("http://www.company.com/logo.png", ImageType.PNG); vcard.addLogo(logo); //binary data byte data[] = ... logo = new Logo(data, ImageType.PNG); vcard.addLogo(logo); //if "ImageType" does not have the pre-defined constant that you need, then create a new instance //arg 1: the value of the 2.1/3.0 TYPE parameter //arg 2: the value to use for the 4.0 MEDIATYPE parameter and for 4.0 data URIs //arg 3: the file extension of the data type (optional) ImageKeyTypeParameter param = new ImageType("bmp", "image/x-ms-bmp", "bmp"); logo = new Logo("http://www.company.com/logo.bmp", param); vcard.addLogo(logo);
Getting the logos
VCard vcard = ... int fileCount = 0; for (Logo logo : vcard.getLogos()){ //the logo will have either a URL or a binary data if (logo.getData() == null){ System.out.println("Logo URL: " + logo.getUrl()); } else { ImageType type = logo.getContentType(); if (type == null) { //the vCard may not have any content type data associated with the logo System.out.println("Saving a logo file..."); } else { System.out.println("Saving a \"" + type.getMediaType() + "\" file..."); } String folder; if (type == ImageType.PNG){ //it is safe to use "==" instead of "equals()" folder = "png-files"; } else { folder = "image-files"; } byte data[] = logo.getData(); String filename = "logo" + fileCount; if (type != null && type.getExtension() != null){ filename += "." + type.getExtension(); } OutputStream out = new FileOutputStream(new File(folder, filename)); out.write(data); out.close(); fileCount++; } }
Property name: LOGO
Supported versions: 2.1, 3.0, 4.0
Field Summary |
---|
Fields inherited from class ezvcard.property.BinaryProperty |
---|
contentType, data, url |
Fields inherited from class ezvcard.property.VCardProperty |
---|
group, parameters |
Constructor Summary | |
---|---|
Logo(byte[] data,
ImageType type)
Creates a logo property. |
|
Logo(File file,
ImageType type)
Creates a logo property. |
|
Logo(InputStream in,
ImageType type)
Creates a logo property. |
|
Logo(String url,
ImageType type)
Creates a logo property. |
Method Summary | |
---|---|
String |
getLanguage()
Gets the language that the property value is written in. |
void |
setLanguage(String language)
Sets the language that the property value is written in. |
Methods inherited from class ezvcard.property.BinaryProperty |
---|
_validate, addPid, getAltId, getContentType, getData, getPids, getPref, getType, getUrl, removePids, setAltId, setContentType, setData, setPref, setType, setUrl |
Methods inherited from class ezvcard.property.VCardProperty |
---|
_supportedVersions, addParameter, compareTo, getGroup, getParameter, getParameters, getParameters, getSupportedVersions, removeParameter, setGroup, setParameter, setParameters, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Logo(String url, ImageType type)
url
- the URL to the logotype
- the content type (e.g. PNG)public Logo(byte[] data, ImageType type)
data
- the binary data of the logotype
- the content type (e.g. PNG)public Logo(InputStream in, ImageType type) throws IOException
in
- an input stream to the binary data (will be closed)type
- the content type (e.g. PNG)
IOException
- if there's a problem reading from the input streampublic Logo(File file, ImageType type) throws IOException
file
- the image filetype
- the content type (e.g. PNG)
IOException
- if there's a problem reading from the fileMethod Detail |
---|
public String getLanguage()
VCardProperty
VCardParameters.getLanguage()
public void setLanguage(String language)
VCardProperty
language
- the language or null to removeVCardParameters.setLanguage(java.lang.String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |