T
- the class used for representing the content type of the resourcepublic abstract class BinaryProperty<T extends MediaTypeParameter> extends VCardProperty implements HasAltId
Modifier and Type | Field and Description |
---|---|
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.
|
group, parameters
Constructor and Description |
---|
BinaryProperty() |
BinaryProperty(BinaryProperty<T> original)
Copy constructor.
|
BinaryProperty(byte[] data,
T type)
Creates a binary property.
|
BinaryProperty(InputStream in,
T type)
Creates a binary property.
|
BinaryProperty(Path file,
T type)
Creates a binary property.
|
BinaryProperty(String url,
T type)
Creates a binary property.
|
Modifier and Type | Method and Description |
---|---|
protected void |
_validate(List<ValidationWarning> warnings,
VCardVersion version,
VCard vcard)
Checks the property for data consistency problems or deviations from the
spec.
|
boolean |
equals(Object obj) |
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<Pid> |
getPids()
Gets the list that stores this property's PID (property ID) parameter
values.
|
Integer |
getPref()
Gets this property's preference value.
|
String |
getType()
Gets the vCard 4.0 TYPE parameter.
|
String |
getUrl()
Gets the URL to the resource
|
int |
hashCode() |
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 this property's 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.
|
protected Map<String,Object> |
toStringValues()
Gets string representations of the class's fields for the
VCardProperty.toString() method. |
addParameter, compareTo, copy, getGroup, getParameter, getParameters, getParameters, getSupportedVersions, isSupportedBy, removeParameter, setGroup, setParameter, setParameters, toString, validate
protected byte[] data
protected T extends MediaTypeParameter contentType
public BinaryProperty()
public BinaryProperty(String url, T type)
url
- the URL to the resourcetype
- the content typepublic BinaryProperty(byte[] data, T type)
data
- the binary datatype
- the content typepublic BinaryProperty(InputStream in, T type) throws IOException
in
- an input stream to the binary data (will be closed)type
- the content typeIOException
- if there is a problem reading from the input streampublic BinaryProperty(Path file, T type) throws IOException
file
- the file containing the binary datatype
- the content typeIOException
- if there is a problem reading from the filepublic BinaryProperty(BinaryProperty<T> original)
original
- the property to make a copy ofpublic byte[] getData()
public void setData(byte[] data, T type)
data
- the binary datatype
- the content type (e.g. "JPEG image")public String getUrl()
public void setUrl(String url, T type)
url
- the URLtype
- the content type (e.g. "JPEG image")public T getContentType()
public void setContentType(T contentType)
contentType
- the content type (e.g. "JPEG image")public String getType()
getContentType()
instead.
Supported versions: 4.0
public void setType(String type)
setContentType(T)
instead.
Supported versions: 4.0
type
- the TYPE value (should be either "work" or "home") or null to
removepublic List<Pid> getPids()
VCardProperty
Gets the list that stores this property's PID (property ID) parameter values.
PIDs can exist on any property where multiple instances are allowed (such
as Email
or Address
, but not StructuredName
because only 1 instance of this property is allowed per vCard).
When used in conjunction with the ClientPidMap
property, it
allows an individual property instance to be uniquely identifiable. This
feature is made use of when two different versions of the same vCard have
to be merged together (called "synchronizing").
Supported versions: 4.0
public Integer getPref()
VCardProperty
Gets this property's preference value. The lower this number is, the more "preferred" the property instance is compared with other properties of the same type. If a property doesn't have a preference value, then it is considered the least preferred.
In the vCard below, the Address
on the second row is the most
preferred because it has the lowest PREF value.
ADR;TYPE=work;PREF=2:;;1600 Amphitheatre Parkway;Mountain View;CA;94043 ADR;TYPE=work;PREF=1:;;One Microsoft Way;Redmond;WA;98052 ADR;TYPE=home:;;123 Maple St;Hometown;KS;12345
Supported versions: 4.0
public void setPref(Integer pref)
VCardProperty
Sets this property's preference value. The lower this number is, the more "preferred" the property instance is compared with other properties of the same type. If a property doesn't have a preference value, then it is considered the least preferred.
In the vCard below, the Address
on the second row is the most
preferred because it has the lowest PREF value.
ADR;TYPE=work;PREF=2:;;1600 Amphitheatre Parkway;Mountain View;CA;94043 ADR;TYPE=work;PREF=1:;;One Microsoft Way;Redmond;WA;98052 ADR;TYPE=home:;;123 Maple St;Hometown;KS;12345
Supported versions: 4.0
pref
- the preference value or null to removepublic String getAltId()
HasAltId
Supported versions: 4.0
getAltId
in interface HasAltId
VCardParameters.getAltId()
public void setAltId(String altId)
HasAltId
Supported versions: 4.0
setAltId
in interface HasAltId
altId
- the ALTID or null to removeVCardParameters.setAltId(java.lang.String)
protected void _validate(List<ValidationWarning> warnings, VCardVersion version, VCard vcard)
VCardProperty
_validate
in class VCardProperty
warnings
- the list to add the warnings toversion
- the version to check the property againstvcard
- the vCard this property belongs toprotected Map<String,Object> toStringValues()
VCardProperty
Gets string representations of the class's fields for the
VCardProperty.toString()
method.
Meant to be overridden by child classes. The default implementation returns an empty map.
toStringValues
in class VCardProperty
public int hashCode()
hashCode
in class VCardProperty
public boolean equals(Object obj)
equals
in class VCardProperty
Copyright © 2012–2023 Michael Angstadt. All rights reserved.