public class Telephone extends VCardProperty implements HasAltId
Defines a telephone number.
Code sample
VCard vcard = new VCard();
//text
Telephone tel = new Telephone("(123) 555-6789");
tel.getTypes().add(TelephoneType.HOME);
tel.setPref(2); //the second-most preferred
vcard.addTelephoneNumber(tel);
//URI (vCard version 4.0 only)
TelUri uri = new TelUri.Builder("+1-800-555-9876").extension("111").build();
tel = new Telephone(uri);
tel.getTypes().add(TelephoneType.WORK);
tel.setPref(1); //the most preferred
vcard.addTelephoneNumber(tel);
Property name: TEL
Supported versions: 2.1, 3.0, 4.0
group, parameters| Constructor and Description |
|---|
Telephone(String text)
Creates a telephone property.
|
Telephone(Telephone original)
Copy constructor.
|
Telephone(TelUri uri)
Creates a telephone 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.
|
Telephone |
copy()
Creates a copy of this property object.
|
boolean |
equals(Object obj) |
String |
getAltId()
Gets the property's ALTID parameter.
|
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 |
getText()
Gets the telephone number as a text value.
|
List<TelephoneType> |
getTypes()
Gets the list that stores this property's telephone types (TYPE
parameters).
|
TelUri |
getUri()
Gets a "tel" URI representing the phone number.
|
int |
hashCode() |
void |
setAltId(String altId)
Sets the property's ALTID parameter.
|
void |
setPref(Integer pref)
Sets this property's preference value.
|
void |
setText(String text)
Sets the telephone number as a text value.
|
void |
setUri(TelUri uri)
Sets a "tel" URI representing the phone number.
|
protected Map<String,Object> |
toStringValues()
Gets string representations of the class's fields for the
VCardProperty.toString() method. |
addParameter, compareTo, getGroup, getParameter, getParameters, getParameters, getSupportedVersions, isSupportedBy, removeParameter, setGroup, setParameter, setParameters, toString, validatepublic Telephone(String text)
text - the telephone number (e.g. "(123) 555-6789")public Telephone(TelUri uri)
uri - a "tel" URI representing the telephone number (vCard 4.0 only)public String getText()
public void setText(String text)
text - the telephone numberpublic TelUri getUri()
Supported versions: 4.0
public void setUri(TelUri uri)
Supported versions: 4.0
uri - the "tel" URIpublic List<TelephoneType> getTypes()
public List<Pid> getPids()
VCardPropertyGets 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()
VCardPropertyGets 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)
VCardPropertySets 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 HasAltIdVCardParameters.getAltId()public void setAltId(String altId)
HasAltId
Supported versions: 4.0
setAltId in interface HasAltIdaltId - the ALTID or null to removeVCardParameters.setAltId(java.lang.String)protected void _validate(List<ValidationWarning> warnings, VCardVersion version, VCard vcard)
VCardProperty_validate in class VCardPropertywarnings - 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 VCardPropertypublic Telephone copy()
VCardPropertyCreates 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(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).
copy in class VCardPropertypublic int hashCode()
hashCode in class VCardPropertypublic boolean equals(Object obj)
equals in class VCardPropertyCopyright © 2012–2023 Michael Angstadt. All rights reserved.