ezvcard.property
Class BinaryProperty<T extends MediaTypeParameter>

java.lang.Object
  extended by ezvcard.property.VCardProperty
      extended by ezvcard.property.BinaryProperty<T>
Type Parameters:
T - the class used for representing the content type of the resource
All Implemented Interfaces:
HasAltId, Comparable<VCardProperty>
Direct Known Subclasses:
ImageProperty, Key, Sound

public abstract class BinaryProperty<T extends MediaTypeParameter>
extends VCardProperty
implements HasAltId

Represents a property whose value contains binary data (for example, Photo).

Author:
Michael Angstadt

Field Summary
protected  T contentType
          The content type of the resource (for example, a JPEG image).
protected  byte[] data
          The decoded data.
protected  String url
          The URL to the resource.
 
Fields inherited from class ezvcard.property.VCardProperty
group, parameters
 
Constructor Summary
BinaryProperty()
           
BinaryProperty(byte[] data, T type)
          Creates a binary property.
BinaryProperty(File file, T type)
          Creates a binary property.
BinaryProperty(InputStream in, T type)
          Creates a binary property.
BinaryProperty(String url, T type)
          Creates a binary property.
 
Method Summary
protected  void _validate(List<Warning> warnings, VCardVersion version, VCard vcard)
          Checks the property for data consistency problems or deviations from the spec.
 void addPid(int localId, int clientPidMapRef)
           Adds a PID value.
 String getAltId()
          Gets the property's ALTID parameter.
 T getContentType()
          Gets the content type of the resource.
 byte[] getData()
          Gets the binary data of the resource.
 List<Integer[]> getPids()
           Gets all PID values.
 Integer getPref()
           Gets the preference value.
 String getType()
          Gets the vCard 4.0 TYPE parameter.
 String getUrl()
          Gets the URL to the resource
 void removePids()
           Removes all PID values.
 void setAltId(String altId)
          Sets the property's ALTID parameter.
 void setContentType(T contentType)
          Sets the content type of the resource.
 void setData(byte[] data, T type)
          Sets the binary data of the resource.
 void setPref(Integer pref)
           Sets the preference value.
 void setType(String type)
          Sets the vCard 4.0 TYPE parameter.
 void setUrl(String url, T type)
          Sets the URL to the resource.
 
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
 

Field Detail

data

protected byte[] data
The decoded data.


url

protected String url
The URL to the resource.


contentType

protected T extends MediaTypeParameter contentType
The content type of the resource (for example, a JPEG image).

Constructor Detail

BinaryProperty

public BinaryProperty()

BinaryProperty

public BinaryProperty(String url,
                      T type)
Creates a binary property.

Parameters:
url - the URL to the resource
type - the content type

BinaryProperty

public BinaryProperty(byte[] data,
                      T type)
Creates a binary property.

Parameters:
data - the binary data
type - the content type

BinaryProperty

public BinaryProperty(InputStream in,
                      T type)
               throws IOException
Creates a binary property.

Parameters:
in - an input stream to the binary data (will be closed)
type - the content type
Throws:
IOException - if there is a problem reading from the input stream

BinaryProperty

public BinaryProperty(File file,
                      T type)
               throws IOException
Creates a binary property.

Parameters:
file - the file containing the binary data
type - the content type
Throws:
IOException - if there is a problem reading from the file
Method Detail

getData

public byte[] getData()
Gets the binary data of the resource.

Returns:
the binary data or null if there is none

setData

public void setData(byte[] data,
                    T type)
Sets the binary data of the resource.

Parameters:
data - the binary data
type - the content type (e.g. "JPEG image")

getUrl

public String getUrl()
Gets the URL to the resource

Returns:
the URL or null if there is none

setUrl

public void setUrl(String url,
                   T type)
Sets the URL to the resource.

Parameters:
url - the URL
type - the content type (e.g. "JPEG image")

getContentType

public T getContentType()
Gets the content type of the resource.

Returns:
the content type (e.g. "JPEG image")

setContentType

public void setContentType(T contentType)
Sets the content type of the resource.

Parameters:
contentType - the content type (e.g. "JPEG image")

getType

public String getType()
Gets the vCard 4.0 TYPE parameter. This should NOT be used to get the TYPE parameter for 2.1/3.0 vCards. Use getContentType() instead.

Supported versions: 4.0

Returns:
the TYPE value (typically, this will be either "work" or "home") or null if it doesn't exist

setType

public void setType(String type)
Sets the vCard 4.0 TYPE parameter. This should NOT be used to set the TYPE parameter for 2.1/3.0 vCards. Use setContentType(T) instead.

Supported versions: 4.0

Parameters:
type - the TYPE value (should be either "work" or "home") or null to remove

getPids

public List<Integer[]> getPids()
Description copied from class: VCardProperty

Gets all PID values.

Supported versions: 4.0

Returns:
the PID values or empty set if there are none
See Also:
VCardParameters.getPids()

addPid

public void addPid(int localId,
                   int clientPidMapRef)
Description copied from class: VCardProperty

Adds a PID value.

Supported versions: 4.0

Parameters:
localId - the local ID
clientPidMapRef - the ID used to reference the property's globally unique identifier in the CLIENTPIDMAP property.
See Also:
VCardParameters.addPid(int, int)

removePids

public void removePids()
Description copied from class: VCardProperty

Removes all PID values.

Supported versions: 4.0

See Also:
VCardParameters.removePids()

getPref

public Integer getPref()
Description copied from class: VCardProperty

Gets the preference value. The lower the number, the more preferred this property instance is compared with other properties in the same vCard of the same type. If a property doesn't have a preference value, then it is considered the least preferred.

Supported versions: 4.0

Returns:
the preference value or null if it doesn't exist
See Also:
VCardParameters.getPref()

setPref

public void setPref(Integer pref)
Description copied from class: VCardProperty

Sets the preference value. The lower the number, the more preferred this property instance is compared with other properties in the same vCard of the same type. If a property doesn't have a preference value, then it is considered the least preferred.

Supported versions: 4.0

Parameters:
pref - the preference value or null to remove
See Also:
VCardParameters.setPref(java.lang.Integer)

getAltId

public String getAltId()
Description copied from interface: HasAltId
Gets the property's ALTID parameter.

Supported versions: 4.0

Specified by:
getAltId in interface HasAltId
Returns:
the ALTID or null if it doesn't exist
See Also:
VCardParameters.getAltId()

setAltId

public void setAltId(String altId)
Description copied from interface: HasAltId
Sets the property's ALTID parameter.

Supported versions: 4.0

Specified by:
setAltId in interface HasAltId
Parameters:
altId - the ALTID or null to remove
See Also:
VCardParameters.setAltId(java.lang.String)

_validate

protected void _validate(List<Warning> warnings,
                         VCardVersion version,
                         VCard vcard)
Description copied from class: VCardProperty
Checks the property for data consistency problems or deviations from the spec. Meant to be overridden by child classes that wish to provide validation logic.

Overrides:
_validate in class VCardProperty
Parameters:
warnings - the list to add the warnings to
version - the version to check the property against
vcard - the vCard this property belongs to


Copyright © 2012-2014 Michael Angstadt. All Rights Reserved.