ezvcard.types
Class ImppType

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

public class ImppType
extends MultiValuedTypeParameterType<ImppTypeParameter>

An instant message handle. The handle is represented as a URI in the format " <IM-PROTOCOL>:<IM-HANDLE>". For example, someone with a Yahoo! Messenger handle of "johndoe@yahoo.com" would have an IMPP vCard property value of "ymsgr:johndoe@yahoo.com".

 VCard vcard = new VCard();
 
 //URI
 ImppType impp = new ImppType("aim:johndoe@aol.com");
 vcard.addImpp(impp);
 
 //static helper constructors
 impp = ImppType.msn("janedoe@msn.com");
 vcard.addImpp(impp);
 

vCard property name: IMPP

vCard versions: 3.0, 4.0

Author:
Michael Angstadt

Nested Class Summary
protected static class ImppType.ImHtmlLink
          Helper class for parsing and building instant messenger links for webpages.
 
Field Summary
static String NAME
           
 
Fields inherited from class ezvcard.types.VCardType
group, subTypes, typeName
 
Constructor Summary
ImppType()
           
ImppType(String uri)
          Constructs a new IMPP type.
ImppType(String protocol, String handle)
          Constructs a new IMPP type.
ImppType(URI uri)
          Constructs a new IMPP type.
 
Method Summary
 void addPid(int localId, int clientPidMapRef)
          Adds a PID value.
static ImppType aim(String handle)
          Creates an IMPP property that contains a AOL Instant Messenger handle.
 String buildLink()
          Builds a URI suitable for use as a link on a webpage.
protected  ImppTypeParameter 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 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 getHandle()
          Gets the IM handle.
 String getMediaType()
          Gets the MEDIATYPE parameter.
 List<Integer[]> getPids()
          Gets all PID parameter values.
 Integer getPref()
          Gets the preference value.
 String getProtocol()
          Gets the IM protocol.
 VCardVersion[] getSupportedVersions()
          Gets the vCard versions that support this type.
 URI getUri()
          Gets the IM URI.
static ImppType icq(String handle)
          Creates an IMPP property that contains an ICQ handle.
static ImppType irc(String handle)
          Creates an IMPP property that contains an IRC handle.
 boolean isAim()
          Determines if this IMPP property contains an AOL Instant Messenger handle.
 boolean isIcq()
          Determines if this IMPP property contains an ICQ handle.
 boolean isIrc()
          Determines if this IMPP property contains an IRC handle.
 boolean isMsn()
          Determines if this IMPP property contains an MSN handle.
 boolean isSip()
          Determines if this IMPP property contains a Session Initiation Protocol handle.
 boolean isSkype()
          Determines if this IMPP property contains a Skype handle.
 boolean isXmpp()
          Determines if this IMPP property contains an Extensible Messaging and Presence Protocol handle.
 boolean isYahoo()
          Determines if this IMPP property contains a Yahoo! Messenger handle.
static ImppType msn(String handle)
          Creates an IMPP property that contains an MSN IMPP property.
protected static URI parseUriFromLink(String linkUri)
          Parses an IM URI from an HTML link.
 void removePids()
          Removes all PID values.
 void setAltId(String altId)
          Sets the ALTID.
 void setMediaType(String mediaType)
          Sets the MEDIATYPE parameter.
 void setPref(Integer pref)
          Sets the preference value.
 void setUri(String uri)
          Sets the IM URI.
 void setUri(String protocol, String handle)
          Sets the IM URI.
 void setUri(URI uri)
          Sets the IM URI.
static ImppType sip(String handle)
          Creates an IMPP property that contains a Session Initiation Protocol handle.
static ImppType skype(String handle)
          Creates an IMPP property that contains a Skype handle.
static ImppType xmpp(String handle)
          Creates an IMPP property that contains an Extensible Messaging and Presence Protocol handle.
static ImppType yahoo(String handle)
          Creates an IMPP property that contains a Yahoo! Messenger handle.
 
Methods inherited from class ezvcard.types.MultiValuedTypeParameterType
addType, getTypes, removeType
 
Methods inherited from class ezvcard.types.VCardType
compareTo, doMarshalSubTypes, 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

ImppType

public ImppType()

ImppType

public ImppType(String uri)
Constructs a new IMPP type. Note that this class has static convenience methods for creating IMPP types of common IM protocols.

Parameters:
uri - the IM URI (e.g. "aim:johndoe@aol.com")
Throws:
IllegalArgumentException - if the URI is not a valid URI

ImppType

public ImppType(URI uri)
Constructs a new IMPP type. Note that this class has static convenience methods for creating IMPP types of common IM protocols.

Parameters:
uri - the IM URI (e.g. "aim:johndoe@aol.com")

ImppType

public ImppType(String protocol,
                String handle)
Constructs a new IMPP type. Note that this class has static convenience methods for creating IMPP types of common IM protocols.

Parameters:
protocol - the IM protocol (e.g. "aim")
handle - the IM handle (e.g. "johndoe@aol.com")
Method Detail

aim

public static ImppType aim(String handle)
Creates an IMPP property that contains a AOL Instant Messenger handle.

Parameters:
handle - the IM handle
Returns:
the IMPP property instance

isAim

public boolean isAim()
Determines if this IMPP property contains an AOL Instant Messenger handle.

Returns:
true if it contains an AOL Instant Messenger handle, false if not

yahoo

public static ImppType yahoo(String handle)
Creates an IMPP property that contains a Yahoo! Messenger handle.

Parameters:
handle - the IM handle
Returns:
the IMPP property instance

isYahoo

public boolean isYahoo()
Determines if this IMPP property contains a Yahoo! Messenger handle.

Returns:
true if it contains a Yahoo! Messenger handle, false if not

msn

public static ImppType msn(String handle)
Creates an IMPP property that contains an MSN IMPP property.

Parameters:
handle - the IM handle
Returns:
the IMPP property instance

isMsn

public boolean isMsn()
Determines if this IMPP property contains an MSN handle.

Returns:
true if it contains an MSN handle, false if not

icq

public static ImppType icq(String handle)
Creates an IMPP property that contains an ICQ handle.

Parameters:
handle - the IM handle
Returns:
the IMPP property instance

isIcq

public boolean isIcq()
Determines if this IMPP property contains an ICQ handle.

Returns:
true if it contains an ICQ handle, false if not

irc

public static ImppType irc(String handle)
Creates an IMPP property that contains an IRC handle.

Parameters:
handle - the IM handle
Returns:
the IMPP property instance

isIrc

public boolean isIrc()
Determines if this IMPP property contains an IRC handle.

Returns:
true if it contains an IRC handle, false if not

sip

public static ImppType sip(String handle)
Creates an IMPP property that contains a Session Initiation Protocol handle.

Parameters:
handle - the IM handle
Returns:
the IMPP property instance

isSip

public boolean isSip()
Determines if this IMPP property contains a Session Initiation Protocol handle.

Returns:
true if it contains a SIP handle, false if not

skype

public static ImppType skype(String handle)
Creates an IMPP property that contains a Skype handle.

Parameters:
handle - the IM handle
Returns:
the IMPP property instance

isSkype

public boolean isSkype()
Determines if this IMPP property contains a Skype handle.

Returns:
true if it contains a Skype handle, false if not

xmpp

public static ImppType xmpp(String handle)
Creates an IMPP property that contains an Extensible Messaging and Presence Protocol handle.

Parameters:
handle - the IM handle
Returns:
the IMPP property instance

isXmpp

public boolean isXmpp()
Determines if this IMPP property contains an Extensible Messaging and Presence Protocol handle.

Returns:
true if it contains an XMPP handle, false if not

getUri

public URI getUri()
Gets the IM URI.

Returns:
the IM URI

setUri

public void setUri(String uri)
Sets the IM URI.

Parameters:
uri - the IM URI (e.g. "aim:theuser@aol.com")
Throws:
IllegalArgumentException - if the URI is not a valid URI

setUri

public void setUri(URI uri)
Sets the IM URI.

Parameters:
uri - the IM URI (e.g. "aim:theuser@aol.com")

setUri

public void setUri(String protocol,
                   String handle)
Sets the IM URI.

Parameters:
protocol - the IM protocol (e.g. "aim")
handle - the IM handle (e.g. "theuser@aol.com")

getProtocol

public String getProtocol()
Gets the IM protocol. Use setUri(String, String) to set the protocol.

Returns:
the IM protocol (e.g. "aim") or null if not set

getHandle

public String getHandle()
Gets the IM handle. Use setUri(String, String) to set the handle.

Returns:
the IM handle (e.g. "johndoe@aol.com") or null if not set

getMediaType

public String getMediaType()
Gets the MEDIATYPE parameter.

vCard versions: 4.0

Returns:
the media type or null if not set

setMediaType

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

vCard versions: 4.0

Parameters:
mediaType - the media type or null to remove

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)

buildTypeObj

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

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

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

parseUriFromLink

protected static URI parseUriFromLink(String linkUri)
Parses an IM URI from an HTML link.

Parameters:
linkUri - the HTML link (e.g. "aim:goim?screenname=theuser")
Returns:
the IM URI or null if not recognized

buildLink

public String buildLink()
Builds a URI suitable for use as a link on a webpage.

Returns:
the link URI (e.g. "aim:goim?screenname=theuser") or null if the IMPP URI was never set


Copyright © 2012-2013. All Rights Reserved.