ezvcard.property
Class VCardProperty

java.lang.Object
  extended by ezvcard.property.VCardProperty
All Implemented Interfaces:
Comparable<VCardProperty>
Direct Known Subclasses:
Address, Agent, BinaryProperty, Birthplace, ClientPidMap, DateOrTimeProperty, Deathplace, Gender, Geo, Impp, ListProperty, Related, SimpleProperty, StructuredName, Telephone, Timezone

public abstract class VCardProperty
extends Object
implements Comparable<VCardProperty>

Represents a vCard key/value pair entry (called a "type" or "property").

Author:
Michael Angstadt

Field Summary
protected  String group
          The group that this property belongs to or null if it doesn't belong to a group.
protected  VCardParameters parameters
          The property's parameters.
 
Constructor Summary
VCardProperty()
           
 
Method Summary
protected  Set<VCardVersion> _supportedVersions()
           Gets the vCard versions that support this property.
protected  void _validate(List<Warning> warnings, VCardVersion version, VCard vcard)
          Checks the property for data consistency problems or deviations from the spec.
 void addParameter(String name, String value)
          Adds a value to a parameter.
 int compareTo(VCardProperty that)
          Sorts by PREF parameter ascending.
 String getGroup()
          Gets this property's group.
 String getParameter(String name)
          Gets the first value of a parameter.
 VCardParameters getParameters()
          Gets all of the property's parameters.
 List<String> getParameters(String name)
          Gets all values of a parameter.
 Set<VCardVersion> getSupportedVersions()
          Gets the vCard versions that support this property.
 void removeParameter(String name)
          Removes a parameter from the property.
 void setGroup(String group)
          Sets this property's group.
 void setParameter(String name, String value)
          Replaces all existing values of a parameter with the given value.
 void setParameters(VCardParameters parameters)
          Sets the property's parameters.
 List<Warning> validate(VCardVersion version, VCard vcard)
          Checks the property for data consistency problems or deviations from the spec.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

group

protected String group
The group that this property belongs to or null if it doesn't belong to a group.


parameters

protected VCardParameters parameters
The property's parameters.

Constructor Detail

VCardProperty

public VCardProperty()
Method Detail

getSupportedVersions

public final Set<VCardVersion> getSupportedVersions()
Gets the vCard versions that support this property.

Returns:
the vCard versions that support this property.

_supportedVersions

protected Set<VCardVersion> _supportedVersions()

Gets the vCard versions that support this property.

This method should be overridden by child classes if the property does not support all vCard versions. The default implementation of this method returns all vCard versions.

Returns:
the vCard versions that support this property.

validate

public final List<Warning> validate(VCardVersion version,
                                    VCard vcard)
Checks the property for data consistency problems or deviations from the spec. These problems will not prevent the property from being written to a data stream, but may prevent it from being parsed correctly by the consuming application. These problems can largely be avoided by reading the Javadocs of the property class, or by being familiar with the vCard standard.

Parameters:
version - the version to check the property against (use 4.0 for xCard and jCard)
vcard - the vCard this property belongs to
Returns:
a list of warnings or an empty list if no problems were found
See Also:
VCard.validate(ezvcard.VCardVersion)

_validate

protected void _validate(List<Warning> warnings,
                         VCardVersion version,
                         VCard vcard)
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.

Parameters:
warnings - the list to add the warnings to
version - the version to check the property against
vcard - the vCard this property belongs to

getParameters

public VCardParameters getParameters()
Gets all of the property's parameters.

Returns:
the property's parameters

setParameters

public void setParameters(VCardParameters parameters)
Sets the property's parameters.

Parameters:
parameters - the parameters

getParameter

public String getParameter(String name)
Gets the first value of a parameter.

Parameters:
name - the parameter name (case insensitive, e.g. "LANGUAGE")
Returns:
the parameter value or null if not found

getParameters

public List<String> getParameters(String name)
Gets all values of a parameter.

Parameters:
name - the parameter name (case insensitive, e.g. "LANGUAGE")
Returns:
the parameter values

setParameter

public void setParameter(String name,
                         String value)
Replaces all existing values of a parameter with the given value.

Parameters:
name - the parameter name (case insensitive, e.g. "LANGUAGE")
value - the parameter value

addParameter

public void addParameter(String name,
                         String value)
Adds a value to a parameter.

Parameters:
name - the parameter name (case insensitive, e.g. "LANGUAGE")
value - the parameter value

removeParameter

public void removeParameter(String name)
Removes a parameter from the property.

Parameters:
name - the parameter name (case insensitive, e.g. "LANGUAGE")

getGroup

public String getGroup()
Gets this property's group.

Returns:
the group or null if it does not belong to a group

setGroup

public void setGroup(String group)
Sets this property's group.

Parameters:
group - the group or null to remove the property's group

compareTo

public int compareTo(VCardProperty that)
Sorts by PREF parameter ascending. Properties that do not have a PREF parameter are pushed to the end of the list.

Specified by:
compareTo in interface Comparable<VCardProperty>


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