ezvcard.types
Class LabelType

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

public class LabelType
extends MultiValuedTypeParameterType<AddressTypeParameter>

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

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

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

 VCard vcard = new VCard();
 AddressType adr = new AddressType();
 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.types.LabelType) method adds a LABEL type to the vCard. However, use of this method is discouraged because it creates a LABEL type that's not associated with an address. Also, orphaned LABELs are ignored when creating version 4.0 vCards because the LABEL type 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 types which the parser could not assign to an address (ADR type). A LABEL is assigned to an ADR if the LABEL's list of TYPE parameters is identical to the ADR's list of TYPE parameters.

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

vCard property name: LABEL

vCard versions: 2.1, 3.0

Author:
Michael Angstadt

Field Summary
static String NAME
           
 
Fields inherited from class ezvcard.types.VCardType
group, subTypes, typeName
 
Constructor Summary
LabelType()
           
LabelType(String label)
           
 
Method Summary
protected  AddressTypeParameter buildTypeObj(String type)
          Builds an object that wraps the value of the TYPE parameter.
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 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.
 String getLanguage()
          Gets the language the note is written in.
 VCardVersion[] getSupportedVersions()
          Gets the vCard versions that support this type.
 String getValue()
          Gets the label value.
 void setLanguage(String language)
          Sets the language that the note is written in.
 void setValue(String value)
          Sets the label value.
 
Methods inherited from class ezvcard.types.MultiValuedTypeParameterType
addType, getTypes, removeType
 
Methods inherited from class ezvcard.types.VCardType
compareTo, doMarshalSubTypes, doMarshalXml, doUnmarshalXml, getGroup, getQName, getSubTypes, 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

LabelType

public LabelType()

LabelType

public LabelType(String label)
Parameters:
label - the label value
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

getValue

public String getValue()
Gets the label value.

Returns:
the label value

setValue

public void setValue(String value)
Sets the label value.

Parameters:
value - the label value

getLanguage

public String getLanguage()
Gets the language the note 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 note is written in.

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

getSupportedVersions

public VCardVersion[] getSupportedVersions()
Description copied from class: VCardType
Gets the vCard versions that support this type.

Overrides:
getSupportedVersions in class VCardType
Returns:
the vCard versions that support this type.

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

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.