ezvcard.types
Class AddressType

java.lang.Object
  extended by ezvcard.types.VCardType
      extended by ezvcard.types.TypeParameterType<T>
          extended by ezvcard.types.MultiValuedTypeParameterType<AddressTypeParameter>
              extended by ezvcard.types.AddressType
All Implemented Interfaces:
Comparable<VCardType>

public class AddressType
extends MultiValuedTypeParameterType<AddressTypeParameter>

A mailing address.

Adding an address

 VCard vcard = new VCard();
 AddressType adr = new AddressType();
 adr.setStreetAddress("123 Main St.");
 adr.setLocality("Austin");
 adr.setRegion("TX");
 adr.setPostalCode("12345");
 adr.setCountry("USA");
 adr.addType(AddressTypeParameter.WORK);
 adr.addType(AddressTypeParameter.DOM);
 
 //optionally, provide the exact text to print out on the mailing label
 adr.setLabel("123 Main St.\nAustin, Tx 12345\nUSA");
 
 vcard.addAddress(adr);
 

Getting the addresses

 VCard vcard = ...
 for (AddressType adr : vcard.getAddresses()){
   ...
 }
 

vCard property name: ADR

vCard versions: 2.1, 3.0, 4.0

Author:
Michael Angstadt

Field Summary
static String NAME
           
 
Fields inherited from class ezvcard.types.VCardType
group, subTypes, typeName
 
Constructor Summary
AddressType()
           
 
Method Summary
 void addPid(int localId, int clientPidMapRef)
          Adds a PID value.
protected  AddressTypeParameter buildTypeObj(String type)
          Builds an object that wraps the value of the TYPE parameter.
protected  void doMarshalSubTypes(VCardSubTypes copy, VCardVersion version, List<String> warnings, CompatibilityMode compatibilityMode, VCard vcard)
          Gets the sub types that will be sent over the wire.
protected  void doMarshalText(StringBuilder sb, VCardVersion version, List<String> warnings, CompatibilityMode compatibilityMode)
          Converts this type object to a string for sending over the wire.
protected  void doMarshalXml(XCardElement parent, List<String> warnings, CompatibilityMode compatibilityMode)
          Marshals this type for inclusion in an xCard (XML document).
protected  void doUnmarshalHtml(HCardElement element, List<String> warnings)
          Unmarshals the type from an hCard (HTML document).
protected  void doUnmarshalText(String value, VCardVersion version, List<String> warnings, CompatibilityMode compatibilityMode)
          Unmarshals the type value from off the wire.
protected  void doUnmarshalXml(XCardElement element, List<String> warnings, CompatibilityMode compatibilityMode)
          Unmarshals the type from an xCard (XML document).
 String getAltId()
          Gets the ALTID.
 String getCountry()
          Gets the country.
 String getExtendedAddress()
          Gets the extended address.
 double[] getGeo()
          Gets the global positioning coordinates that are associated with this address.
 String getLabel()
          Gets the label of the address.
 String getLanguage()
          Gets the language that the address is written in.
 String getLocality()
          Gets the locality (city)
 List<Integer[]> getPids()
          Gets all PID parameter values.
 String getPoBox()
          Gets the P.O.
 String getPostalCode()
          Gets the postal code.
 Integer getPref()
          Gets the preference value.
 String getRegion()
          Gets the region.
 String getStreetAddress()
          Gets the street address
 String getTimezone()
          Gets the timezone that's associated with this address.
 void removePids()
          Removes all PID values.
 void setAltId(String altId)
          Sets the ALTID.
 void setCountry(String country)
          Sets the country.
 void setExtendedAddress(String extendedAddress)
          Sets the extended address.
 void setGeo(double latitude, double longitude)
          Sets the global positioning coordinates that are associated with this address.
 void setLabel(String label)
          Sets the label of the address.
 void setLanguage(String language)
          Sets the language that the address is written in.
 void setLocality(String locality)
          Sets the locality (city).
 void setPoBox(String poBox)
          Sets the P.O.
 void setPostalCode(String postalCode)
          Sets the postal code.
 void setPref(Integer pref)
          Sets the preference value.
 void setRegion(String region)
          Sets the region.
 void setStreetAddress(String streetAddress)
          Sets the street address.
 void setTimezone(String timezone)
          Sets the timezone that's associated with this address.
 
Methods inherited from class ezvcard.types.MultiValuedTypeParameterType
addType, getTypes, removeType
 
Methods inherited from class ezvcard.types.VCardType
compareTo, getGroup, getQName, getSubTypes, getSupportedVersions, getTypeName, marshalSubTypes, marshalText, marshalXml, setGroup, unmarshalHtml, unmarshalText, unmarshalXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final String NAME
See Also:
Constant Field Values
Constructor Detail

AddressType

public AddressType()
Method Detail

buildTypeObj

protected AddressTypeParameter buildTypeObj(String type)
Description copied from class: TypeParameterType
Builds an object that wraps the value of the TYPE parameter.

Specified by:
buildTypeObj in class TypeParameterType<AddressTypeParameter>
Parameters:
type - the value of the TYPE parameter
Returns:
the object wrapper

getPoBox

public String getPoBox()
Gets the P.O. (post office) box.

Returns:
the P.O. box or null if not set

setPoBox

public void setPoBox(String poBox)
Sets the P.O. (post office) box.

Parameters:
poBox - the P.O. box or null to remove

getExtendedAddress

public String getExtendedAddress()
Gets the extended address.

Returns:
the extended address (e.g. "Suite 200") or null if not set

setExtendedAddress

public void setExtendedAddress(String extendedAddress)
Sets the extended address.

Parameters:
extendedAddress - the extended address (e.g. "Suite 200") or null to remove

getStreetAddress

public String getStreetAddress()
Gets the street address

Returns:
the street address (e.g. "123 Main St")

setStreetAddress

public void setStreetAddress(String streetAddress)
Sets the street address.

Parameters:
streetAddress - the street address (e.g. "123 Main St") or null to remove

getLocality

public String getLocality()
Gets the locality (city)

Returns:
the locality (e.g. "Boston") or null if not set

setLocality

public void setLocality(String locality)
Sets the locality (city).

Parameters:
locality - the locality or null to remove

getRegion

public String getRegion()
Gets the region.

Returns:
the region (e.g. "Texas") or null if not set

setRegion

public void setRegion(String region)
Sets the region.

Parameters:
region - the region (e.g. "Texas") or null to remove

getPostalCode

public String getPostalCode()
Gets the postal code.

Returns:
the postal code (e.g. "90210") or null if not set

setPostalCode

public void setPostalCode(String postalCode)
Sets the postal code.

Parameters:
postalCode - the postal code (e.g. "90210") or null to remove

getCountry

public String getCountry()
Gets the country.

Returns:
the country (e.g. "USA") or null if not set

setCountry

public void setCountry(String country)
Sets the country.

Parameters:
country - the country (e.g. "USA") or null to remove

getLanguage

public String getLanguage()
Gets the language that the address is written in.

Returns:
the language or null if not set
See Also:
VCardSubTypes.getLanguage()

setLanguage

public void setLanguage(String language)
Sets the language that the address is written in.

Parameters:
language - the language or null to remove
See Also:
VCardSubTypes.setLanguage(java.lang.String)

getLabel

public String getLabel()
Gets the label of the address.

Returns:
the label or null if it doesn't have one

setLabel

public void setLabel(String label)
Sets the label of the address.

Parameters:
label - the label or null to remove

getGeo

public double[] getGeo()
Gets the global positioning coordinates that are associated with this address.

vCard versions: 4.0

Returns:
the latitude (index 0) and longitude (index 1) or null if not set or null if the parameter value was in an incorrect format
See Also:
VCardSubTypes.getGeo()

setGeo

public void setGeo(double latitude,
                   double longitude)
Sets the global positioning coordinates that are associated with this address.

vCard versions: 4.0

Parameters:
latitude - the latitude
longitude - the longitude
See Also:
VCardSubTypes.setGeo(double, double)

getPids

public List<Integer[]> getPids()
Gets all PID parameter values.

vCard versions: 4.0

Returns:
the PID values or empty set if there are none
See Also:
VCardSubTypes.getPids()

addPid

public void addPid(int localId,
                   int clientPidMapRef)
Adds a PID value.

vCard 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:
VCardSubTypes.addPid(int, int)

removePids

public void removePids()
Removes all PID values.

vCard versions: 4.0

See Also:
VCardSubTypes.removePids()

getPref

public Integer getPref()
Gets the preference value.

vCard versions: 4.0

Returns:
the preference value or null if it doesn't exist
See Also:
VCardSubTypes.getPref()

setPref

public void setPref(Integer pref)
Sets the preference value.

vCard versions: 4.0

Parameters:
pref - the preference value or null to remove
See Also:
VCardSubTypes.setPref(java.lang.Integer)

getAltId

public String getAltId()
Gets the ALTID.

vCard versions: 4.0

Returns:
the ALTID or null if it doesn't exist
See Also:
VCardSubTypes.getAltId()

setAltId

public void setAltId(String altId)
Sets the ALTID.

vCard versions: 4.0

Parameters:
altId - the ALTID or null to remove
See Also:
VCardSubTypes.setAltId(java.lang.String)

getTimezone

public String getTimezone()
Gets the timezone that's associated with this address.

vCard versions: 4.0

Returns:
the timezone (e.g. "America/New_York") or null if it doesn't exist

setTimezone

public void setTimezone(String timezone)
Sets the timezone that's associated with this address.

vCard versions: 4.0

Parameters:
timezone - the timezone (e.g. "America/New_York") or null to remove

doMarshalSubTypes

protected void doMarshalSubTypes(VCardSubTypes copy,
                                 VCardVersion version,
                                 List<String> warnings,
                                 CompatibilityMode compatibilityMode,
                                 VCard vcard)
Description copied from class: VCardType
Gets the sub types that will be sent over the wire.

If this method is NOT overridden, then the type's sub types will be sent over the wire as-is. In other words, whatever is in the VCardType.subTypes field will be sent. Child classes can override this method in order to modify the sub types before they are marshalled.

Overrides:
doMarshalSubTypes in class VCardType
Parameters:
copy - the sub types that will be marshalled into the vCard. This object is a copy of the VCardType.subTypes field, so any modifications done to this object will not effect the state of the field.
version - the version vCard that is being generated
warnings - allows the programmer to alert the user to any note-worthy (but non-critical) issues that occurred during the marshalling process
compatibilityMode - allows the programmer to customize the marshalling process depending on the expected consumer of the vCard
vcard - the VCard object that is being marshalled

doMarshalText

protected void doMarshalText(StringBuilder sb,
                             VCardVersion version,
                             List<String> warnings,
                             CompatibilityMode compatibilityMode)
Description copied from class: VCardType
Converts this type object to a string for sending over the wire. It is NOT responsible for folding.

Specified by:
doMarshalText in class VCardType
Parameters:
sb - the buffer to add the marshalled value to
version - the version vCard that is being generated
warnings - allows the programmer to alert the user to any note-worthy (but non-critical) issues that occurred during the marshalling process
compatibilityMode - allows the programmer to customize the marshalling process depending on the expected consumer of the vCard

doUnmarshalText

protected void doUnmarshalText(String value,
                               VCardVersion version,
                               List<String> warnings,
                               CompatibilityMode compatibilityMode)
Description copied from class: VCardType
Unmarshals the type value from off the wire.

Specified by:
doUnmarshalText in class VCardType
Parameters:
value - the unfolded value from off the wire. If the wire value is in the "quoted-printable" encoding, it will be decoded.
version - the version of the vCard that is being read or null if the VERSION type has not been parsed yet (v3.0 and v4.0 require that the VERSION type be at the top of the vCard, but v2.1 has no such requirement)
warnings - allows the programmer to alert the user to any note-worthy (but non-critical) issues that occurred during the unmarshalling process
compatibilityMode - allows you to customize the unmarshalling process depending on where the vCard came from

doMarshalXml

protected void doMarshalXml(XCardElement parent,
                            List<String> warnings,
                            CompatibilityMode compatibilityMode)
Description copied from class: VCardType
Marshals this type for inclusion in an xCard (XML document). All child classes SHOULD override this, but are not required to.

Overrides:
doMarshalXml in class VCardType
Parameters:
parent - the XML element that the type's value will be inserted into. For example, this would be the "<fn>" element for the "FN" type.
warnings - allows the programmer to alert the user to any note-worthy (but non-critical) issues that occurred during the marshalling process
compatibilityMode - allows the programmer to customize the marshalling process depending on the expected consumer of the vCard

doUnmarshalXml

protected void doUnmarshalXml(XCardElement element,
                              List<String> warnings,
                              CompatibilityMode compatibilityMode)
Description copied from class: VCardType
Unmarshals the type from an xCard (XML document).

Overrides:
doUnmarshalXml in class VCardType
Parameters:
element - the XML element that contains the type data. For example, this would be the "<fn>" element for the "FN" type. This object will NOT include the "<parameters>" child element (it is removed after being unmarshalled into a VCardSubTypes object).
warnings - allows the programmer to alert the user to any note-worthy (but non-critical) issues that occurred during the unmarshalling process
compatibilityMode - allows the programmer to customize the unmarshalling process depending on where the vCard came from

doUnmarshalHtml

protected void doUnmarshalHtml(HCardElement element,
                               List<String> warnings)
Description copied from class: VCardType
Unmarshals the type from an hCard (HTML document).

Overrides:
doUnmarshalHtml in class VCardType
Parameters:
element - the HTML element that contains the type data.
warnings - allows the programmer to alert the user to any note-worthy (but non-critical) issues that occurred during the unmarshalling process


Copyright © 2012-2013. All Rights Reserved.