|
Smack | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jivesoftware.smack.packet.Packet
org.jivesoftware.smack.packet.IQ
org.jivesoftware.smackx.packet.VCard
public class VCard
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
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.jivesoftware.smack.packet.IQ |
---|
IQ.Type |
Field Summary |
---|
Fields inherited from class org.jivesoftware.smack.packet.Packet |
---|
DEFAULT_LANGUAGE, 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 |
byte[] |
getAvatar()
Return the byte representation of the avatar(if one exists), otherwise returns null if no avatar could be found. |
String |
getAvatarHash()
Returns the SHA-1 Hash of the Avatar image. |
static byte[] |
getBytes(URL url)
Common code for getting the bytes of a url. |
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 |
setAvatar(byte[] bytes)
Specify the bytes for the avatar to use. |
void |
setAvatar(byte[] bytes,
String mimeType)
Specify the bytes for the avatar to use as well as the mime type. |
void |
setAvatar(URL avatarURL)
Set the avatar for the VCard by specifying the url to the image. |
void |
setEmailHome(String email)
|
void |
setEmailWork(String emailWork)
|
void |
setEncodedImage(String encodedAvatar)
Set the encoded avatar string. |
void |
setField(String field,
String value)
Set generic VCard field. |
void |
setField(String field,
String value,
boolean isUnescapable)
Set generic, unescapable 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, getDefaultLanguage, getError, getExtension, getExtension, getExtensions, getExtensionsXML, getFrom, getPacketID, getProperty, getPropertyNames, getTo, getXmlns, nextID, parseXMLLang, removeExtension, setDefaultXmlns, setError, setFrom, setPacketID, setProperty, setTo |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public VCard()
Method Detail |
---|
public String getField(String field)
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.public void setField(String field, String value)
value
- value of fieldfield
- field to set. See getField(String)
getField(String)
public void setField(String field, String value, boolean isUnescapable)
value
- value of fieldfield
- field to set. See getField(String)
isUnescapable
- True if the value should not be escaped, and false if it should.public String getFirstName()
public void setFirstName(String firstName)
public String getLastName()
public void setLastName(String lastName)
public String getMiddleName()
public void setMiddleName(String middleName)
public String getNickName()
public void setNickName(String nickName)
public String getEmailHome()
public void setEmailHome(String email)
public String getEmailWork()
public void setEmailWork(String emailWork)
public String getJabberId()
public void setJabberId(String jabberId)
public String getOrganization()
public void setOrganization(String organization)
public String getOrganizationUnit()
public void setOrganizationUnit(String organizationUnit)
public String getAddressFieldHome(String addrField)
addrField
- one of POSTAL, PARCEL, (DOM | INTL), PREF, POBOX, EXTADR, STREET,
LOCALITY, REGION, PCODE, CTRYpublic void setAddressFieldHome(String addrField, String value)
addrField
- one of POSTAL, PARCEL, (DOM | INTL), PREF, POBOX, EXTADR, STREET,
LOCALITY, REGION, PCODE, CTRYpublic String getAddressFieldWork(String addrField)
addrField
- one of POSTAL, PARCEL, (DOM | INTL), PREF, POBOX, EXTADR, STREET,
LOCALITY, REGION, PCODE, CTRYpublic void setAddressFieldWork(String addrField, String value)
addrField
- one of POSTAL, PARCEL, (DOM | INTL), PREF, POBOX, EXTADR, STREET,
LOCALITY, REGION, PCODE, CTRYpublic void setPhoneHome(String phoneType, String phoneNum)
phoneType
- one of VOICE, FAX, PAGER, MSG, CELL, VIDEO, BBS, MODEM, ISDN, PCS, PREFphoneNum
- phone numberpublic String getPhoneHome(String phoneType)
phoneType
- one of VOICE, FAX, PAGER, MSG, CELL, VIDEO, BBS, MODEM, ISDN, PCS, PREFpublic void setPhoneWork(String phoneType, String phoneNum)
phoneType
- one of VOICE, FAX, PAGER, MSG, CELL, VIDEO, BBS, MODEM, ISDN, PCS, PREFphoneNum
- phone numberpublic String getPhoneWork(String phoneType)
phoneType
- one of VOICE, FAX, PAGER, MSG, CELL, VIDEO, BBS, MODEM, ISDN, PCS, PREFpublic void setAvatar(URL avatarURL)
avatarURL
- the url to the image(png,jpeg,gif,bmp)public void setAvatar(byte[] bytes)
bytes
- the bytes of the avatar.public void setAvatar(byte[] bytes, String mimeType)
bytes
- the bytes of the avatar.mimeType
- the mime type of the avatar.public void setEncodedImage(String encodedAvatar)
encodedAvatar
- the encoded avatar string.public byte[] getAvatar()
// Load Avatar from VCard byte[] avatarBytes = vCard.getAvatar();// To create an ImageIcon for Swing applications ImageIcon icon = new ImageIcon(avatar);
// To create just an image object from the bytes ByteArrayInputStream bais = new ByteArrayInputStream(avatar); try { Image image = ImageIO.read(bais); } catch (IOException e) { e.printStackTrace(); }
public static byte[] getBytes(URL url) throws IOException
url
- the url to read.
IOException
public String getAvatarHash()
public void save(XMPPConnection connection) throws XMPPException
NOTE: the method is asynchronous and does not wait for the returned value.
connection
- the XMPPConnection to use.
XMPPException
- thrown if there was an issue setting the VCard in the server.public void load(XMPPConnection connection) throws XMPPException
XMPPException
public void load(XMPPConnection connection, String user) throws XMPPException
XMPPException
public String getChildElementXML()
IQ
Extensions of this class must override this method.
getChildElementXML
in class IQ
public boolean equals(Object o)
equals
in class Packet
public int hashCode()
hashCode
in class Packet
public String toString()
toString
in class Object
|
Smack | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |