ezvcard.property
Class Label

java.lang.Object
  extended by ezvcard.property.VCardProperty
      extended by ezvcard.property.SimpleProperty<String>
          extended by ezvcard.property.TextProperty
              extended by ezvcard.property.Label
All Implemented Interfaces:
Comparable<VCardProperty>

public class Label
extends TextProperty

Defines the exact text to put on the mailing label when mailing a package or letter to the person.

The LABEL property is not supported in 4.0. Instead, labels are included as a parameter to their corresponding Address. When marshalling a vCard, ez-vcard will use either the LABEL property or the LABEL parameter, depending on the requested vCard version.

To add a label to a vCard, the Address.setLabel(java.lang.String) method should be used.

 VCard vcard = new VCard();
 Address adr = new Address();
 adr.setStreetAddress("123 Main St.");
 adr.setLocality("Austin");
 adr.setRegion("TX");
 adr.setPostalCode("12345");
 adr.setLabel("123 Main St.\nAustin, TX 12345"); //newlines are allowed
 vcard.addAddress(adr);
 

The VCard.addOrphanedLabel(ezvcard.property.Label) method adds a LABEL property to the vCard. However, use of this method is discouraged because it creates a LABEL property that's not associated with an address. Also, orphaned LABEL properties are ignored when creating version 4.0 vCards because the LABEL property is not supported by vCard 4.0.

The VCard.getOrphanedLabels() method can be used after parsing a version 2.1 or 3.0 vCard to retrieve any LABEL properties which the parser could not assign to an address. A LABEL is assigned to an address if the LABEL's list of TYPE parameters is identical to the address's list of TYPE parameters.

 VCard vcard = ...
 for (Label label : vcard.getOrphanedLabels()) {
        System.out.println(label.getValue());
 }
 

Property name: LABEL

Supported versions: 2.1, 3.0

Author:
Michael Angstadt

Field Summary
 
Fields inherited from class ezvcard.property.SimpleProperty
value
 
Fields inherited from class ezvcard.property.VCardProperty
group, parameters
 
Constructor Summary
Label(String label)
          Creates a label property.
 
Method Summary
 Set<VCardVersion> _supportedVersions()
           Gets the vCard versions that support this property.
 void addType(AddressType type)
          Adds a TYPE parameter.
 String getLanguage()
          Gets the language that the property value is written in.
 Set<AddressType> getTypes()
          Gets all the TYPE parameters.
 void removeType(AddressType type)
          Removes a TYPE parameter.
 void setLanguage(String language)
          Sets the language that the property value is written in.
 
Methods inherited from class ezvcard.property.SimpleProperty
_validate, getValue, setValue
 
Methods inherited from class ezvcard.property.VCardProperty
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

Label

public Label(String label)
Creates a label property.

Parameters:
label - the label value
Method Detail

_supportedVersions

public Set<VCardVersion> _supportedVersions()
Description copied from class: VCardProperty

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.

Overrides:
_supportedVersions in class VCardProperty
Returns:
the vCard versions that support this property.

getTypes

public Set<AddressType> getTypes()
Gets all the TYPE parameters.

Returns:
the TYPE parameters or empty set if there are none

addType

public void addType(AddressType type)
Adds a TYPE parameter.

Parameters:
type - the TYPE parameter to add

removeType

public void removeType(AddressType type)
Removes a TYPE parameter.

Parameters:
type - the TYPE parameter to remove

getLanguage

public String getLanguage()
Description copied from class: VCardProperty
Gets the language that the property value is written in.

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

setLanguage

public void setLanguage(String language)
Description copied from class: VCardProperty
Sets the language that the property value is written in.

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


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