public abstract class VCardProperty extends Object implements Comparable<VCardProperty>
Modifier and Type | Field and Description |
---|---|
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.
|
Modifier | Constructor and Description |
---|---|
|
VCardProperty() |
protected |
VCardProperty(VCardProperty original)
Copy constructor.
|
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.
|
void |
addParameter(String name,
String value)
Adds a value to a parameter.
|
int |
compareTo(VCardProperty that)
Sorts by PREF parameter ascending.
|
VCardProperty |
copy()
Creates a copy of this property object.
|
boolean |
equals(Object obj) |
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.
|
VCardVersion[] |
getSupportedVersions()
Gets the vCard versions that support this property.
|
int |
hashCode() |
boolean |
isSupportedBy(VCardVersion version)
Determines if this property is supported by the given vCard version.
|
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.
|
String |
toString() |
protected Map<String,Object> |
toStringValues()
Gets string representations of the class's fields for the
toString() method. |
List<ValidationWarning> |
validate(VCardVersion version,
VCard vcard)
Checks the property for data consistency problems or deviations from the
spec.
|
protected String group
protected VCardParameters parameters
public VCardProperty()
protected VCardProperty(VCardProperty original)
original
- the property to make a copy ofpublic final VCardVersion[] getSupportedVersions()
Gets the vCard versions that support this property.
The supported versions are defined by assigning a
@SupportedVersions
annotation to the property
class. Property classes without this annotation are considered to be
supported by all versions.
public final boolean isSupportedBy(VCardVersion version)
Determines if this property is supported by the given vCard version.
The supported versions are defined by assigning a
SupportedVersions
annotation to the property class. Property
classes without this annotation are considered to be supported by all
versions.
version
- the vCard versionpublic final List<ValidationWarning> validate(VCardVersion version, VCard vcard)
version
- the version to check the property against (use 4.0 for
xCard and jCard)vcard
- the vCard this property belongs toVCard.validate(ezvcard.VCardVersion)
protected void _validate(List<ValidationWarning> warnings, VCardVersion version, VCard vcard)
warnings
- the list to add the warnings toversion
- the version to check the property againstvcard
- the vCard this property belongs topublic VCardParameters getParameters()
public void setParameters(VCardParameters parameters)
parameters
- the parameters (cannot be null)public String getParameter(String name)
name
- the parameter name (case insensitive, e.g. "LANGUAGE")public List<String> getParameters(String name)
name
- the parameter name (case insensitive, e.g. "LANGUAGE")public void setParameter(String name, String value)
name
- the parameter name (case insensitive, e.g. "LANGUAGE")value
- the parameter valuepublic void addParameter(String name, String value)
name
- the parameter name (case insensitive, e.g. "LANGUAGE")value
- the parameter valuepublic void removeParameter(String name)
name
- the parameter name (case insensitive, e.g. "LANGUAGE")public String getGroup()
public void setGroup(String group)
group
- the group or null to remove the property's grouppublic int compareTo(VCardProperty that)
compareTo
in interface Comparable<VCardProperty>
protected Map<String,Object> toStringValues()
Gets string representations of the class's fields for the
toString()
method.
Meant to be overridden by child classes. The default implementation returns an empty map.
public VCardProperty copy()
Creates a copy of this property object.
The default implementation of this method uses reflection to look for a copy constructor. Child classes SHOULD override this method to avoid the performance overhead involved in using reflection.
The child class's copy constructor, if present, MUST invoke the
VCardProperty(VCardProperty)
super constructor to ensure that
the group name and parameters are also copied.
This method MUST be overridden by the child class if the child class does
not have a copy constructor. Otherwise, an
UnsupportedOperationException
will be thrown when an attempt is
made to copy the property (such as in the VCard
class's copy constructor
).
UnsupportedOperationException
- if the class does not have a copy
constructor or there is a problem invoking itCopyright © 2012–2023 Michael Angstadt. All rights reserved.