Smack

org.jivesoftware.smackx.packet
Class VCard

java.lang.Object
  extended byorg.jivesoftware.smack.packet.Packet
      extended byorg.jivesoftware.smack.packet.IQ
          extended byorg.jivesoftware.smackx.packet.VCard

public class VCard
extends IQ

A VCard class for use with the SMACK jabber library.

You should refer to the JEP-54 documentation.

Please note that this class is incomplete but it does provide the most commonly found information in vCards. Also remember that VCard transfer is not a standard, and the protocol may change or be replaced.

Usage:


 // To save VCard:

 VCard vCard = new VCard();
 vCard.setFirstName("kir");
 vCard.setLastName("max");
 vCard.setEmailHome("foo@fee.bar");
 vCard.setJabberId("jabber@id.org");
 vCard.setOrganization("Jetbrains, s.r.o");
 vCard.setNickName("KIR");

 vCard.setField("TITLE", "Mr");
 vCard.setAddressFieldHome("STREET", "Some street");
 vCard.setAddressFieldWork("CTRY", "US");
 vCard.setPhoneWork("FAX", "3443233");

 vCard.save(connection);

 // To load VCard:

 VCard vCard = new VCard();
 vCard.load(conn); // load own VCard
 vCard.load(conn, "joe@foo.bar"); // load someone's VCard
 

Author:
Kirill Maximov (kir@maxkir.com)

Nested Class Summary
 
Nested classes inherited from class org.jivesoftware.smack.packet.IQ
IQ.Type
 
Field Summary
 
Fields inherited from class org.jivesoftware.smack.packet.Packet
ID_NOT_AVAILABLE
 
Constructor Summary
VCard()
           
 
Method Summary
 boolean equals(Object o)
           
 String getAddressFieldHome(String addrField)
          Get home address field
 String getAddressFieldWork(String addrField)
          Get work address field
 String getChildElementXML()
          Returns the sub-element XML section of the IQ packet, or null if there isn't one.
 String getEmailHome()
           
 String getEmailWork()
           
 String getField(String field)
          Set generic VCard field.
 String getFirstName()
           
 String getJabberId()
           
 String getLastName()
           
 String getMiddleName()
           
 String getNickName()
           
 String getOrganization()
           
 String getOrganizationUnit()
           
 String getPhoneHome(String phoneType)
          Get home phone number
 String getPhoneWork(String phoneType)
          Get work phone number
 int hashCode()
           
 void load(XMPPConnection connection)
          Load VCard information for a connected user.
 void load(XMPPConnection connection, String user)
          Load VCard information for a given user.
 void save(XMPPConnection connection)
          Save this vCard for the user connected by 'connection'.
 void setAddressFieldHome(String addrField, String value)
          Set home address field
 void setAddressFieldWork(String addrField, String value)
          Set work address field
 void setEmailHome(String email)
           
 void setEmailWork(String emailWork)
           
 void setField(String field, String value)
          Set generic VCard field.
 void setFirstName(String firstName)
           
 void setJabberId(String jabberId)
           
 void setLastName(String lastName)
           
 void setMiddleName(String middleName)
           
 void setNickName(String nickName)
           
 void setOrganization(String organization)
           
 void setOrganizationUnit(String organizationUnit)
           
 void setPhoneHome(String phoneType, String phoneNum)
          Set home phone number
 void setPhoneWork(String phoneType, String phoneNum)
          Set work phone number
 String toString()
           
 
Methods inherited from class org.jivesoftware.smack.packet.IQ
getType, setType, toXML
 
Methods inherited from class org.jivesoftware.smack.packet.Packet
addExtension, deleteProperty, getError, getExtension, getExtensions, getExtensionsXML, getFrom, getPacketID, getProperty, getPropertyNames, getTo, removeExtension, setError, setFrom, setPacketID, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setTo
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VCard

public VCard()
Method Detail

getField

public String getField(String field)
Set generic VCard field.

Parameters:
field - value of field. Possible values: NICKNAME, PHOTO, BDAY, JABBERID, MAILER, TZ, GEO, TITLE, ROLE, LOGO, NOTE, PRODID, REV, SORT-STRING, SOUND, UID, URL, DESC.

setField

public void setField(String field,
                     String value)
Set generic VCard field.

Parameters:
value - value of field
field - field to set. See getField(String)
See Also:
getField(String)

getFirstName

public String getFirstName()

setFirstName

public void setFirstName(String firstName)

getLastName

public String getLastName()

setLastName

public void setLastName(String lastName)

getMiddleName

public String getMiddleName()

setMiddleName

public void setMiddleName(String middleName)

getNickName

public String getNickName()

setNickName

public void setNickName(String nickName)

getEmailHome

public String getEmailHome()

setEmailHome

public void setEmailHome(String email)

getEmailWork

public String getEmailWork()

setEmailWork

public void setEmailWork(String emailWork)

getJabberId

public String getJabberId()

setJabberId

public void setJabberId(String jabberId)

getOrganization

public String getOrganization()

setOrganization

public void setOrganization(String organization)

getOrganizationUnit

public String getOrganizationUnit()

setOrganizationUnit

public void setOrganizationUnit(String organizationUnit)

getAddressFieldHome

public String getAddressFieldHome(String addrField)
Get home address field

Parameters:
addrField - one of POSTAL, PARCEL, (DOM | INTL), PREF, POBOX, EXTADR, STREET, LOCALITY, REGION, PCODE, CTRY

setAddressFieldHome

public void setAddressFieldHome(String addrField,
                                String value)
Set home address field

Parameters:
addrField - one of POSTAL, PARCEL, (DOM | INTL), PREF, POBOX, EXTADR, STREET, LOCALITY, REGION, PCODE, CTRY

getAddressFieldWork

public String getAddressFieldWork(String addrField)
Get work address field

Parameters:
addrField - one of POSTAL, PARCEL, (DOM | INTL), PREF, POBOX, EXTADR, STREET, LOCALITY, REGION, PCODE, CTRY

setAddressFieldWork

public void setAddressFieldWork(String addrField,
                                String value)
Set work address field

Parameters:
addrField - one of POSTAL, PARCEL, (DOM | INTL), PREF, POBOX, EXTADR, STREET, LOCALITY, REGION, PCODE, CTRY

setPhoneHome

public void setPhoneHome(String phoneType,
                         String phoneNum)
Set home phone number

Parameters:
phoneType - one of VOICE, FAX, PAGER, MSG, CELL, VIDEO, BBS, MODEM, ISDN, PCS, PREF
phoneNum - phone number

getPhoneHome

public String getPhoneHome(String phoneType)
Get home phone number

Parameters:
phoneType - one of VOICE, FAX, PAGER, MSG, CELL, VIDEO, BBS, MODEM, ISDN, PCS, PREF

setPhoneWork

public void setPhoneWork(String phoneType,
                         String phoneNum)
Set work phone number

Parameters:
phoneType - one of VOICE, FAX, PAGER, MSG, CELL, VIDEO, BBS, MODEM, ISDN, PCS, PREF
phoneNum - phone number

getPhoneWork

public String getPhoneWork(String phoneType)
Get work phone number

Parameters:
phoneType - one of VOICE, FAX, PAGER, MSG, CELL, VIDEO, BBS, MODEM, ISDN, PCS, PREF

save

public void save(XMPPConnection connection)
Save this vCard for the user connected by 'connection'. Connection should be authenticated and not anonymous.

NOTE: the method is asynchronous and does not wait for the returned value.


load

public void load(XMPPConnection connection)
          throws XMPPException
Load VCard information for a connected user. Connection should be authenticated and not anonymous.

Throws:
XMPPException

load

public void load(XMPPConnection connection,
                 String user)
          throws XMPPException
Load VCard information for a given user. Connection should be authenticated and not anonymous.

Throws:
XMPPException

getChildElementXML

public String getChildElementXML()
Description copied from class: IQ
Returns the sub-element XML section of the IQ packet, or null if there isn't one. Packet extensions must be included, if any are defined.

Extensions of this class must override this method.

Specified by:
getChildElementXML in class IQ
Returns:
the child element section of the IQ XML.

equals

public boolean equals(Object o)

hashCode

public int hashCode()

toString

public String toString()

Smack

Copyright © 2003 Jive Software.