ezvcard.types
Class RelatedType

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

public class RelatedType
extends MultiValuedTypeParameterType<RelatedTypeParameter>

Someone that the person is related to. It can contain either a URI or a plain text value.

 VCard vcard = new VCard();
 
 RelatedType related = new RelatedType();
 related.addType(RelatedTypeParameter.FRIEND);
 related.setUri("urn:uuid:03a0e51f-d1aa-4385-8a53-e29025acd8af");
 vcard.addRelated(related);
 
 related = new RelatedType();
 related.addType(RelatedTypeParameter.CO_WORKER);
 related.addType(RelatedTypeParameter.FRIEND);
 related.setUri("http://joesmoe.name/vcard.vcf");
 vcard.addRelated(related);
 
 related = new RelatedType();
 related.addType(RelatedTypeParameter.SPOUSE);
 related.setText("My wife's name is Edna Smith");
 vcard.addRelated(related);
 

vCard property name: RELATED

vCard versions: 4.0

Author:
Michael Angstadt

Field Summary
static String NAME
           
 
Fields inherited from class ezvcard.types.VCardType
group, subTypes, typeName
 
Constructor Summary
RelatedType()
           
 
Method Summary
 void addPid(int localId, int clientPidMapRef)
          Adds a PID value.
protected  RelatedTypeParameter 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 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.
 List<Integer[]> getPids()
          Gets all PID parameter values.
 Integer getPref()
          Gets the preference value.
 VCardVersion[] getSupportedVersions()
          Gets the vCard versions that support this type.
 String getText()
          Gets the text value.
 String getUri()
          Gets the URI value.
 void removePids()
          Removes all PID values.
 void setAltId(String altId)
          Sets the ALTID.
 void setPref(Integer pref)
          Sets the preference value.
 void setText(String text)
          Sets the value to free-form text instead of a URI.
 void setUri(String uri)
          Sets the URI.
 void setUriEmail(String email)
          Sets the URI to an email address.
 void setUriIM(String protocol, String handle)
          Sets the URI to an instant messaging handle.
 void setUriTelephone(String telephone)
          Sets the URI to a telephone number.
 
Methods inherited from class ezvcard.types.MultiValuedTypeParameterType
addType, getTypes, removeType
 
Methods inherited from class ezvcard.types.VCardType
compareTo, doUnmarshalHtml, 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

RelatedType

public RelatedType()
Method Detail

getUri

public String getUri()
Gets the URI value.

Returns:
the URI value or null if no URI value is set

setUriEmail

public void setUriEmail(String email)
Sets the URI to an email address.

Parameters:
email - the email address

setUriIM

public void setUriIM(String protocol,
                     String handle)
Sets the URI to an instant messaging handle.

Parameters:
protocol - the IM protocol (e.g. "aim")
handle - the handle

setUriTelephone

public void setUriTelephone(String telephone)
Sets the URI to a telephone number.

Parameters:
telephone - the telephone number

setUri

public void setUri(String uri)
Sets the URI.

Parameters:
uri - the URI

getText

public String getText()
Gets the text value.

Returns:
the text value or null if no text value is set

setText

public void setText(String text)
Sets the value to free-form text instead of a URI.

Parameters:
text - the text

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)

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.

buildTypeObj

protected RelatedTypeParameter 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<RelatedTypeParameter>
Parameters:
type - the value of the TYPE parameter
Returns:
the object wrapper

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


Copyright © 2012-2013. All Rights Reserved.