ezvcard.property
Class Timezone

java.lang.Object
  extended by ezvcard.property.VCardProperty
      extended by ezvcard.property.Timezone
All Implemented Interfaces:
HasAltId, Comparable<VCardProperty>

public class Timezone
extends VCardProperty
implements HasAltId

Contains the timezone that the person lives/works in.

Code sample

 VCard vcard = new VCard();
 Timezone tz = new Timezone(-5, 0, "America/New_York");
 vcard.addTimezone(tz);
 

Property name: TZ

Supported versions: 2.1, 3.0, 4.0

Author:
Michael Angstadt

Field Summary
 
Fields inherited from class ezvcard.property.VCardProperty
group, parameters
 
Constructor Summary
Timezone(Integer hourOffset, Integer minuteOffset)
          Creates a timezone property.
Timezone(Integer hourOffset, Integer minuteOffset, String text)
          Creates a timezone property.
Timezone(String text)
          Creates a timezone property.
Timezone(TimeZone timezone)
          Creates a timezone property.
Timezone(UtcOffset offset)
          Creates a timezone property.
Timezone(UtcOffset offset, String text)
          Creates a timezone 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.
 Integer getHourOffset()
          Gets the hour component of the UTC offset.
 String getMediaType()
          Gets the MEDIATYPE parameter.
 Integer getMinuteOffset()
          Gets the minute component of the UTC offset.
 UtcOffset getOffset()
          Gets the UTC offset.
 List<Integer[]> getPids()
           Gets all PID values.
 Integer getPref()
           Gets the preference value.
 String getText()
          Gets the text portion of the timezone.
 String getType()
          Gets the TYPE parameter.
 void removePids()
           Removes all PID values.
 void setAltId(String altId)
          Sets the property's ALTID parameter.
 void setMediaType(String mediaType)
          Sets the MEDIATYPE parameter.
 void setOffset(int hourOffset, int minuteOffset)
          Sets the UTC offset.
 void setOffset(UtcOffset offset)
          Sets the UTC offset.
 void setPref(Integer pref)
           Sets the preference value.
 void setText(String text)
          Sets the text portion of the timezone.
 void setType(String type)
          Sets the TYPE parameter.
 TimeZone toTimeZone()
          Creates a TimeZone representation of this class.
 
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
 

Constructor Detail

Timezone

public Timezone(String text)
Creates a timezone property.

Parameters:
text - a free-form string representing the timezone, preferably a timezone ID from the Olson Database (e.g. "America/New_York")

Timezone

public Timezone(Integer hourOffset,
                Integer minuteOffset)
Creates a timezone property.

Parameters:
hourOffset - the hour component of the UTC offset (e.g. -5)
minuteOffset - the minute component of the UTC offset (e.g. 0)

Timezone

public Timezone(UtcOffset offset)
Creates a timezone property.

Parameters:
offset - the UTC offset

Timezone

public Timezone(Integer hourOffset,
                Integer minuteOffset,
                String text)
Creates a timezone property.

Parameters:
hourOffset - the hour component of the UTC offset (e.g. -5)
minuteOffset - the minute component of the UTC offset (e.g. 0)
text - a free-form string representing the timezone, preferably a timezone ID from the Olson Database (e.g. "America/New_York")

Timezone

public Timezone(UtcOffset offset,
                String text)
Creates a timezone property.

Parameters:
offset - the UTC offset
text - a free-form string representing the timezone, preferably a timezone ID from the Olson Database (e.g. "America/New_York")

Timezone

public Timezone(TimeZone timezone)
Creates a timezone property.

Parameters:
timezone - the timezone
Method Detail

getHourOffset

public Integer getHourOffset()
Gets the hour component of the UTC offset.

Returns:
the hour component of the UTC offset or null if not set

getMinuteOffset

public Integer getMinuteOffset()
Gets the minute component of the UTC offset.

Returns:
the minute component of the UTC offset or null if not set

getOffset

public UtcOffset getOffset()
Gets the UTC offset.

Returns:
the UTC offset or null if not set

setOffset

public void setOffset(int hourOffset,
                      int minuteOffset)
Sets the UTC offset.

Parameters:
hourOffset - the hour offset (e.g. -5)
minuteOffset - the minute offset (e.g. 0)

setOffset

public void setOffset(UtcOffset offset)
Sets the UTC offset.

Parameters:
offset - the UTC offset

getText

public String getText()
Gets the text portion of the timezone.

Returns:
the free-form string representing the timezone, such as a timezone ID from the Olson Database (e.g. "America/New_York")

setText

public void setText(String text)
Sets the text portion of the timezone.

Parameters:
text - a free-form string representing the timezone, preferably a timezone ID from the Olson Database (e.g. "America/New_York")

toTimeZone

public TimeZone toTimeZone()
Creates a TimeZone representation of this class.

Returns:
a TimeZone object or null if this object contains no offset data

getType

public String getType()
Gets the TYPE parameter.

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 TYPE parameter.

Supported versions: 4.0

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

getMediaType

public String getMediaType()
Gets the MEDIATYPE parameter.

Supported versions: 4.0

Returns:
the media type or null if not set

setMediaType

public void setMediaType(String mediaType)
Sets the MEDIATYPE parameter.

Supported versions: 4.0

Parameters:
mediaType - the media type 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.