Java Doc for Contact.java in  » 6.0-JDK-Modules » j2me » com » sun » kvem » midp » pim » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » com.sun.kvem.midp.pim 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


com.sun.kvem.midp.pim.Contact

All known Subclasses:   com.sun.kvem.midp.pim.ContactImpl,
Contact
public interface Contact extends PIMItem(Code)
Represents a single Contact entry in a PIM Contact database. The supported field list for a Contact is also a subset of the fields defined by the vCard specification from the Internet Mail Consortium (http://www.imc.org). This set of fields included in this Contact class represents those necessary to provide the relevant information about a contact without compromising platform portability.

The Contact class has many different fields that it can support. However, each individual Contact object supports only fields valid for its associated list. Its ContactList restricts what fields in a Contact are retained. This reflects that some native Contact databases do not support all of the fields available in a Contact item. The methods AbstractPIMList.isSupportedField and AbstractPIMList.getSupportedAttributes can be used to determine if particular Contact fields and types are supported by a ContactList and therefore persisted when the Contact is committed to its list. Attempts to add or get data based on fields not supported in the Contact's ContactList result in a javax.microedition.pim.UnsupportedFieldException .

Data

The following table details the explicitly defined fields that may by in a Contact. Implementations may extend the field set using extended fields as defined in PIMItem.

Table: Standard Fields

Fields Type of Data Associated with Field
NAME, ADDR PIMItem.STRING_ARRAY
EMAIL, FORMATTED_NAME, NICKNAME, NOTE, ORG, TEL, TITLE, UID, URL PIMItem.STRING
BIRTHDAY, REVISION PIMItem.DATE
PHOTO, PUBLIC_KEY PIMItem.BINARY
PHOTO_URL, PUBLIC_KEY_STRING PIMItem.STRING
CLASS PIMItem.INT

Required Field Support

All Contact fields may or may not be supported by a particular list. This is due to the fact that underlying native databases may not support all of the fields defined in this API. Support for any of the fields can be determined by the method AbstractPIMList.isSupportedField .

Native Contact databases may require some of the fields to have values assigned to them in order to be persisted. If an application does not provide values for these fields, default values are provided for the Contact by the VM when the Contact is persisted.

Examples

Explicit Field Use with Field Checking

This first example shows explicit field access in which each field is properly checked for support prior to use. This results in code that is more portable across PIM implementations regardless of which specific fields are supported on particular PIM list implementations. If one of the fields is not supported by the list, the field is not set in the Contact.
 ContactList contacts = null;
 try {
 contacts = (ContactList) PIM.getInstance().openPIMList(PIM.CONTACT_LIST,
 PIM.READ_WRITE);
 } catch (PIMException e) {
 // An error occurred
 return;
 }
 Contact contact = contacts.createContact();
 String[] addr = new String[contacts.stringArraySize(Contact.ADDR)];
 String[] name = new String[contacts.stringArraySize(Contact.NAME)];
 if (contacts.isSupportedField(Contact.NAME_FORMATTED)
 contact.addString(Contact.NAME_FORMATTED, PIMItem.ATTR_NONE,
 "Mr. John Q. Public, Esq.");
 if (contacts.isSupportedArrayElement(Contact.NAME, Contact.NAME_FAMILY))
 name[Contact.NAME_FAMILY] = "Public";
 if (contacts.isSupportedArrayElement(Contact.NAME, Contact.NAME_GIVEN))
 name[Contact.NAME_GIVEN] = "John";
 contact.addStringArray(Contact.NAME, PIMItem.ATTR_NONE, name);
 if (contacts.isSupportedArrayElement(Contact.ADDR, Contact.ADDR_COUNTRY))
 addr[Contact.ADDR_COUNTRY] = "USA";
 if (contacts.isSupportedArrayElement(Contact.ADDR, Contact.ADDR_LOCALITY))
 addr[Contact.ADDR_LOCALITY] = "Coolsville";
 if (contacts.isSupportedArrayElement(Contact.ADDR, Contact.ADDR_POSTALCODE))
 addr[Contact.ADDR_POSTALCODE] = "91921-1234";
 if (contacts.isSupportedArrayElement(Contact.ADDR, Contact.ADDR_STREET))
 addr[Contact.ADDR_STREET] = "123 Main Street";
 if (contacts.isSupportedField(Contact.ADDR))
 contact.addStringArray(Contact.ADDR, Contact.ATTR_HOME, addr);
 if (contacts.isSupportedField(Contact.TEL))
 contact.addString(Contact.TEL, Contact.ATTR_HOME, "613-123-4567");
 if (contacts.maxCategories() != 0
 && contacts.isCategory("Friends"))
 contact.addToCategory("Friends");
 if (contacts.isSupportedField(Contact.BIRTHDAY))
 contact.addDate(Contact.BIRTHDAY, PIMItem.ATTR_NONE,
 new Date().getTime());
 if (contacts.isSupportedField(Contact.EMAIL)) {
 contact.addString(Contact.EMAIL,
 Contact.ATTR_HOME | Contact.ATTR_PREFERRED,
 "jqpublic@xyz.dom1.com");
 }
 try {
 contact.commit();
 } catch (PIMException e) {
 // An error occured
 }
 try {
 contacts.close();
 } catch (PIMException e) {
 }
 

Explicit Field Use with Exception Handling

This second example also shows explicit field access that properly handles optionally supported fields by use of a try catch block with UnsupportedFieldException. In this case, the setting of the whole Contact is rejected if any of the fields are not supported in the particular list implementation.
 ContactList contacts = null;
 try {
 contacts = (ContactList) PIM.getInstance().openPIMList(PIM.CONTACT_LIST,
 PIM.READ_WRITE);
 } catch (PIMException e) {
 // An error occurred
 return;
 }
 Contact contact = contacts.createContact();
 String[] name = new String[contacts.stringArraySize(Contact.NAME)];
 name[Contact.NAME_GIVEN] = "John";
 name[Contact.NAME_FAMILY] = "Public";
 String[] addr = new String[contacts.stringArraySize(Contact.ADDR)];
 addr[Contact.ADDR_COUNTRY] = "USA";
 addr[Contact.ADDR_LOCALITY] = "Coolsville";
 addr[Contact.ADDR_POSTALCODE] = "91921-1234";
 addr[Contact.ADDR_STREET] = "123 Main Street";
 try {
 contact.addString(Contact.NAME_FORMATTED, PIMItem.ATTR_NONE,
 "Mr. John Q. Public, Esq.");
 contact.addStringArray(Contact.NAME, PIMItem.ATTR_NONE, name);
 contact.addStringArray(Contact.ADDR, Contact.ATTR_HOME, addr);
 contact.addString(Contact.TEL, Contact.ATTR_HOME, "613-123-4567");
 contact.addToCategory("Friends");
 contact.addDate(Contact.BIRTHDAY, PIMItem.ATTR_NONE,
 new Date().getTime());
 contact.addString(Contact.EMAIL,
 Contact.ATTR_HOME | Contact.ATTR_PREFERRED,
 "jqpublic@xyz.dom1.com");
 } catch (UnsupportedFieldException e) {
 // In this case, we choose not to save the contact at all if any of the
 // fields are not supported on this platform.
 System.out.println("Contact not saved");
 return;
 }
 try {
 contact.commit();
 } catch (PIMException e) {
 // An error occured
 }
 try {
 contacts.close();
 } catch (PIMException e) {
 }
 

See Also:    Internet
See Also:   Mail Consortium PDI

See Also:   ContactListImpl
since:
   PIM 1.0


Field Summary
final public static  intADDR
     Field specifying an address for this Contact.
final public static  intADDR_COUNTRY
     Index into the string array for an address field, where the data at this index represents the country of a particular address.
final public static  intADDR_EXTRA
     Index into the string array for an address field, where the data at this index represents any extra info of a particular address.
final public static  intADDR_LOCALITY
     Index into the string array for an address field, where the data at this index represents the locality (for example, a city) of a particular address.
final public static  intADDR_POBOX
     Index into the string array for an address field, where the data at this index represents the post office box of a particular address.
final public static  intADDR_POSTALCODE
     Index into the string array for an address field, where the data at this index represents the postal code (for example, a zip code) of a particular address.
final public static  intADDR_REGION
     Index into the string array for an address field, where the data at this index represents the region (for example, a province, state, or territory) of a particular address.
final public static  intADDR_STREET
     Index into the string array for an address field, where the data at this index represents the street information of a particular address.
final public static  intATTR_ASST
     Attribute classifying a data value as related to an ASSISTANT.
final public static  intATTR_AUTO
     Attribute classifying a data value as related to AUTO.
final public static  intATTR_FAX
     Attribute classifying a data value as related to FAX.
final public static  intATTR_HOME
     Attribute classifying a data value as related to HOME.
final public static  intATTR_MOBILE
     Attribute classifying a data value as related to MOBILE.
final public static  intATTR_OTHER
     Attribute classifying a data value as "OTHER".
final public static  intATTR_PAGER
     Attribute classifying a data value as related to PAGER.
final public static  intATTR_PREFERRED
     Attribute classifying a data value with preferred status for retrieval or display purposes (platform specific).
final public static  intATTR_SMS
     Attribute classifying a data value as related to SMS.
final public static  intATTR_WORK
     Attribute classifying a data value as related to WORK.
final public static  intBIRTHDAY
     Field for the birthday of the Contact.
final public static  intCLASS
     Field specifying the desired access class for this contact.
final public static  intCLASS_CONFIDENTIAL
     Constant indicating this contact's class of access is confidential.
final public static  intCLASS_PRIVATE
     Constant indicating this contact's class of access is private.
final public static  intCLASS_PUBLIC
     Constant indicating this contact's class of access is public.
final public static  intEMAIL
     Field for an e-mail address.
final public static  intFORMATTED_ADDR
     Field represents a formatted version of a complete address for the Contact entry.
final public static  intFORMATTED_NAME
     Field represents a formatted version of a name for the Contact entry.
final public static  intNAME
     Field specifying the name for this contact.
final public static  intNAME_FAMILY
     Index into the string array for a name field, where the data at this index represents the family name.
final public static  intNAME_GIVEN
     Index into the string array for a name field, where the data at this index represents the given name.
final public static  intNAME_OTHER
     Index into the string array for a name field, where the data at this index represents other alternate name or names.
final public static  intNAME_PREFIX
     Index into the string array for a name field, where the data at this index represents a prefix to a name.
final public static  intNAME_SUFFIX
     Index into the string array for a name field, where the data at this index represents a suffix to a name.
final public static  intNICKNAME
     Field where the data represents a nickname.
final public static  intNOTE
     Field specifying supplemental information or a comment associated with a Contact.
final public static  intORG
     Field specifying the organization name or units associated with a Contact.
final public static  intPHOTO
     Field specifying a photo for a Contact.
final public static  intPHOTO_URL
     Field specifying a photo of a Contact.
final public static  intPUBLIC_KEY
     Field specifying the public encryption key for a Contact. Data associated with this field is inline binary encoded data. Manipulation of this field may affect data stored in the PUBLIC_KEY_STRING field since some implementation may use the same memory for both fields (e.g.
final public static  intPUBLIC_KEY_STRING
     Field specifying the public encryption key for a Contact. Data associated with this field is of String type. Manipulation of this field may affect data stored in the PUBLIC_KEY field since some implementation may use the same memory for both fields (e.g.
final public static  intREVISION
     Field specifying the last modification date and time of a Contact item.
final public static  intTEL
     Field for a voice telephone number.
final public static  intTITLE
     Field specifying the job title for a Contact.
final public static  intUID
     Field specifying a unique ID for a Contact.
final public static  intURL
     Field specifying the uniform resource locator for a Contact.



Field Detail
ADDR
final public static int ADDR(Code)
Field specifying an address for this Contact. Data for this field is of STRING_ARRAY type.



ADDR_COUNTRY
final public static int ADDR_COUNTRY(Code)
Index into the string array for an address field, where the data at this index represents the country of a particular address. Data for this field is of String type.



ADDR_EXTRA
final public static int ADDR_EXTRA(Code)
Index into the string array for an address field, where the data at this index represents any extra info of a particular address. Data for this field is of String type.



ADDR_LOCALITY
final public static int ADDR_LOCALITY(Code)
Index into the string array for an address field, where the data at this index represents the locality (for example, a city) of a particular address. Data for this field is of String type.



ADDR_POBOX
final public static int ADDR_POBOX(Code)
Index into the string array for an address field, where the data at this index represents the post office box of a particular address. Data for this field is of String type.



ADDR_POSTALCODE
final public static int ADDR_POSTALCODE(Code)
Index into the string array for an address field, where the data at this index represents the postal code (for example, a zip code) of a particular address. Data for this field is of String type.



ADDR_REGION
final public static int ADDR_REGION(Code)
Index into the string array for an address field, where the data at this index represents the region (for example, a province, state, or territory) of a particular address. Data for this field is of String type.



ADDR_STREET
final public static int ADDR_STREET(Code)
Index into the string array for an address field, where the data at this index represents the street information of a particular address. Data for this field is of String type.



ATTR_ASST
final public static int ATTR_ASST(Code)
Attribute classifying a data value as related to an ASSISTANT.



ATTR_AUTO
final public static int ATTR_AUTO(Code)
Attribute classifying a data value as related to AUTO.



ATTR_FAX
final public static int ATTR_FAX(Code)
Attribute classifying a data value as related to FAX.



ATTR_HOME
final public static int ATTR_HOME(Code)
Attribute classifying a data value as related to HOME.



ATTR_MOBILE
final public static int ATTR_MOBILE(Code)
Attribute classifying a data value as related to MOBILE.



ATTR_OTHER
final public static int ATTR_OTHER(Code)
Attribute classifying a data value as "OTHER".



ATTR_PAGER
final public static int ATTR_PAGER(Code)
Attribute classifying a data value as related to PAGER.



ATTR_PREFERRED
final public static int ATTR_PREFERRED(Code)
Attribute classifying a data value with preferred status for retrieval or display purposes (platform specific). Only one value in a field may be marked as preferred. Subsequent assigning of preferred status to values in a field overrides any previous preferred status indications.



ATTR_SMS
final public static int ATTR_SMS(Code)
Attribute classifying a data value as related to SMS.



ATTR_WORK
final public static int ATTR_WORK(Code)
Attribute classifying a data value as related to WORK.



BIRTHDAY
final public static int BIRTHDAY(Code)
Field for the birthday of the Contact. Data for this field is expressed in the same long value format as java.util.Date, which is milliseconds since the epoch (00:00:00 GMT, January 1, 1970).

Note that the value provided may be rounded-down by an implementation due to platform restrictions. For example, should a native Contact database only support contact date values with granularity in terms of seconds, then the provided date value is rounded down to a date time with a full second.




CLASS
final public static int CLASS(Code)
Field specifying the desired access class for this contact. Data associated with this field is of int type, and can be one of the values Contact.CLASS_PRIVATE , Contact.CLASS_PUBLIC , or Contact.CLASS_CONFIDENTIAL .



CLASS_CONFIDENTIAL
final public static int CLASS_CONFIDENTIAL(Code)
Constant indicating this contact's class of access is confidential.



CLASS_PRIVATE
final public static int CLASS_PRIVATE(Code)
Constant indicating this contact's class of access is private.



CLASS_PUBLIC
final public static int CLASS_PUBLIC(Code)
Constant indicating this contact's class of access is public.



EMAIL
final public static int EMAIL(Code)
Field for an e-mail address. Data for this field is of String type.



FORMATTED_ADDR
final public static int FORMATTED_ADDR(Code)
Field represents a formatted version of a complete address for the Contact entry. This string is typically a single string containing the complete address separated with CRLF separators. This field is typically present for contact databases that support only one field for a contact's address, or for specifying address label format. Data for this field is of STRING type. For example:
"123 Main St. Anytown, CA 99999 USA"



FORMATTED_NAME
final public static int FORMATTED_NAME(Code)
Field represents a formatted version of a name for the Contact entry. Data for this field is of STRING type. The string data associated with this field conforms to the X.520 Common Name attribute format. For example:
"Mr. John Q. Public, Esq."



NAME
final public static int NAME(Code)
Field specifying the name for this contact. Data for this field is of STRING_ARRAY type.



NAME_FAMILY
final public static int NAME_FAMILY(Code)
Index into the string array for a name field, where the data at this index represents the family name. For example:
"Stevenson"



NAME_GIVEN
final public static int NAME_GIVEN(Code)
Index into the string array for a name field, where the data at this index represents the given name. For example:
"Johnathan"



NAME_OTHER
final public static int NAME_OTHER(Code)
Index into the string array for a name field, where the data at this index represents other alternate name or names. For example:
"John, Johnny"



NAME_PREFIX
final public static int NAME_PREFIX(Code)
Index into the string array for a name field, where the data at this index represents a prefix to a name. For example:
"Dr."



NAME_SUFFIX
final public static int NAME_SUFFIX(Code)
Index into the string array for a name field, where the data at this index represents a suffix to a name. For example:
"M.D., A.C.P."



NICKNAME
final public static int NICKNAME(Code)
Field where the data represents a nickname. Data for this field is of STRING type. For example:
"Copier Man"



NOTE
final public static int NOTE(Code)
Field specifying supplemental information or a comment associated with a Contact. Data for this field is of String type. The data associated with this field follows the X.520 Description data format. For example:
"The fax number is operational 0800 to 1715 EST, Mon-Fri."



ORG
final public static int ORG(Code)
Field specifying the organization name or units associated with a Contact. Data for this field is of String type. The data associated with this field is based on the X.520 Organization data format. For example:
"ABC Inc."



PHOTO
final public static int PHOTO(Code)
Field specifying a photo for a Contact. Data associated with this field is inline binary. Manipulation of this field may affect data stored in the PHOTO_URL field since some implementation may use the same memory for both fields (e.g. one can either have PHOTO or have PHOTO_URL but not both).
See Also:   AbstractPIMList.isSupportedField



PHOTO_URL
final public static int PHOTO_URL(Code)
Field specifying a photo of a Contact. Data associated with this field is of String type, representing a URL for the photo. Manipulation of this field may affect data stored in the PHOTO field since some implementation may use the same memory for both fields (e.g. one can either have PHOTO or have PHOTO_URL but not both).
See Also:   AbstractPIMList.isSupportedField



PUBLIC_KEY
final public static int PUBLIC_KEY(Code)
Field specifying the public encryption key for a Contact. Data associated with this field is inline binary encoded data. Manipulation of this field may affect data stored in the PUBLIC_KEY_STRING field since some implementation may use the same memory for both fields (e.g. one can either have PUBLIC_KEY or have PUBLIC_KEY_STRING but not both).



PUBLIC_KEY_STRING
final public static int PUBLIC_KEY_STRING(Code)
Field specifying the public encryption key for a Contact. Data associated with this field is of String type. Manipulation of this field may affect data stored in the PUBLIC_KEY field since some implementation may use the same memory for both fields (e.g. one can either have PUBLIC_KEY or have PUBLIC_KEY_STRING but not both).



REVISION
final public static int REVISION(Code)
Field specifying the last modification date and time of a Contact item. If the Contact has ever been committed to a ContactList, then this attribute becomes read only. This field is set automatically on imports and commits of a Contact. Data for this field is expressed in the same long value format as java.util.Date, which is milliseconds since the epoch (00:00:00 GMT, January 1, 1970).

Note that the value provided may be rounded-down by an implementation due to platform restrictions. For example, should a native Contact database only support contact date values with granularity in terms of seconds, then the provided date value is rounded down to a date time with a full second.




TEL
final public static int TEL(Code)
Field for a voice telephone number. Data associated with this field is of String type and can be any valid String. No telephone formatting is enforced since many native implementations allow free form text to be associated with TEL fields.



TITLE
final public static int TITLE(Code)
Field specifying the job title for a Contact. Data for this field is of String type. This title is based on the X.520 Title attributes. For example:
"Director, Research and Development"



UID
final public static int UID(Code)
Field specifying a unique ID for a Contact. This field can be used to check for identity using String.equals. UID is read only if the Contact has been committed to a ContactList at least once in its lifetime. The UID is not set if the Contact has never been committed to a ContactList; countValues(UID) returns 0 before a newly created Contact object is committed to its list. The attribute is valid for the persistent life of the Contact and may be reused by the platform once this particular Contact is deleted. Data for this field is of String data type.



URL
final public static int URL(Code)
Field specifying the uniform resource locator for a Contact. Data for this field is of String data type. For example:
"http://www.swbyps.restaurant.french/~chezchic.html"





www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.