⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 contact.html

📁 J2ME PDA开发PIM的技术规范,可使应用程序查看手机本地联系人列表, 本地文件
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd">
<!--NewPage-->
<HTML>
	<HEAD>
		<TITLE>Contact (PIM Optional Package 1.0 Spec, Final Release) </TITLE>
		<!-- Generated by javadoc on Wed Oct 29 13:13:40 PST 2003 -->
		<META NAME="keywords" CONTENT="javax.microedition.pim.Contact,Contact interface">
		<LINK REL="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
			<SCRIPT>
function asd()
{
parent.document.title="Contact (PIM Optional Package 1.0 Spec, Final Release)";
}
			</SCRIPT>
	</HEAD>
	<BODY BGCOLOR="white" onload="asd();">
		<!-- ========== START OF NAVBAR ========== -->
		<A NAME="navbar_top"><!-- --></A>
		<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0">
			<TR>
				<TD COLSPAN="3" BGCOLOR="#eeeeff" CLASS="NavBarCell1">
					<A NAME="navbar_top_firstrow"><!-- --></A>
					<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">
						<TR ALIGN="center" VALIGN="top">
							<TD BGCOLOR="#eeeeff" CLASS="NavBarCell1">
								<A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>
							<TD BGCOLOR="#eeeeff" CLASS="NavBarCell1">
								<A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>
							<TD BGCOLOR="#ffffff" CLASS="NavBarCell1Rev">
								&nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>
							<TD BGCOLOR="#eeeeff" CLASS="NavBarCell1">
								<A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>
							<TD BGCOLOR="#eeeeff" CLASS="NavBarCell1">
								<A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>
							<TD BGCOLOR="#eeeeff" CLASS="NavBarCell1">
								<A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>
							<TD BGCOLOR="#eeeeff" CLASS="NavBarCell1">
								<A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>
						</TR>
					</TABLE>
				</TD>
				<TD ALIGN="right" VALIGN="top" ROWSPAN="3"><EM> PIM Optional Package 1.0<br>
						Final Release</EM>
				</TD>
			</TR>
			<TR>
				<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> &nbsp;PREV CLASS&nbsp; &nbsp;<A HREF="../../../javax/microedition/pim/ContactList.html"><B>NEXT 
								CLASS</B></A></FONT></TD>
				<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html" TARGET="_top">
							<B>FRAMES</B></A> &nbsp; &nbsp;<A HREF="Contact.html" TARGET="_top"><B>NO FRAMES</B></A>
						&nbsp; &nbsp;
						<SCRIPT>  <!--  if(window==top) {    document.writeln('<A HREF="../../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');  }  //--></SCRIPT>
						<NOSCRIPT>
							<A HREF="../../../allclasses-noframe.html" TARGET=""><B>All Classes</B></A>
						</NOSCRIPT>
					</FONT>
				</TD>
			</TR>
			<TR>
				<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD>
				<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;CONSTR&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD>
			</TR>
		</TABLE>
		<!-- =========== END OF NAVBAR =========== -->
		<HR>
		<!-- ======== START OF CLASS DATA ======== -->
		<H2>
			<FONT SIZE="-1">javax.microedition.pim</FONT>
			<BR>
			Interface Contact</H2>
		<DL>
			<DT><B>All Superinterfaces:</B>
				<DD>
					<A HREF="../../../javax/microedition/pim/PIMItem.html">PIMItem</A></DD>
		</DL>
		<HR>
		<DL>
			<DT>public interface <B>Contact</B><DT>extends <A HREF="../../../javax/microedition/pim/PIMItem.html">
						PIMItem</A></DT></DL>
		<P>
		<P>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.
		</P>
		<P>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 <A HREF="../../../javax/microedition/pim/PIMList.html#isSupportedField(int)">
				<CODE>PIMList.isSupportedField(int)</CODE></A> and <A HREF="../../../javax/microedition/pim/PIMList.html#getSupportedAttributes(int)">
				<CODE>PIMList.getSupportedAttributes(int)</CODE></A> 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 <A HREF="../../../javax/microedition/pim/UnsupportedFieldException.html">
				<CODE>UnsupportedFieldException</CODE></A>.
		</P>
		<H3>Data</H3>
		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.
		<h4>Table: Standard Fields</h4>
		<table border="1">
			<TR>
				<th>
					Fields
				</th>
				<th>
					Type of Data Associated with Field
				</th>
			</TR>
			<tr>
				<td><code>NAME, ADDR</code></td>
				<td><code>PIMItem.STRING_ARRAY</code></td>
			</tr>
			<tr>
				<td><code>EMAIL, FORMATTED_NAME, NICKNAME, NOTE, ORG, TEL, TITLE, UID, URL</code></td>
				<td><code>PIMItem.STRING</code></td>
			</tr>
			<tr>
				<td><code>BIRTHDAY, REVISION</code></td>
				<td><code>PIMItem.DATE</code></td>
			</tr>
			<tr>
				<td><code>PHOTO, PUBLIC_KEY</code></td>
				<td><code>PIMItem.BINARY</code></td>
			</tr>
			<tr>
				<td><code>PHOTO_URL, PUBLIC_KEY_STRING</code></td>
				<td><code>PIMItem.STRING</code></td>
			</tr>
			<tr>
				<td><code>CLASS</code></td>
				<td><code>PIMItem.INT</code></td>
			</tr>
		</table>
		<h3>Required Field Support</h3>
		<P>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 <A HREF="../../../javax/microedition/pim/PIMList.html#isSupportedField(int)">
				<CODE>PIMList.isSupportedField(int)</CODE></A>.
		</P>
		<P>
			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.
		</P>
		<h3>Examples</h3>
		<h4>Explicit Field Use with Field Checking</h4>
		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.
		<pre> 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
       &amp;&amp; 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) {
 }
 </pre>
		<h4>Explicit Field Use with Exception Handling</h4>
		This second example also shows explicit field access that properly handles 
		optionally supported fields by use of a try catch block with <code>UnsupportedFieldException</code>. 
		In this case, the setting of the whole Contact is rejected if any of the fields 
		are not supported in the particular list implementation.
		<PRE>  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) {
  }
 </PRE>
		<P>
		<P>
			<DL>
				<DT><B>Since:</B>
					<DD>
						PIM 1.0 <DT><B>See Also:</B><DD><A target="_top" href="http://www.imc.org/pdi">Internet 
									Mail Consortium PDI</A>, <A HREF="../../../javax/microedition/pim/ContactList.html">
									<CODE>ContactList</CODE></A></DD></DL>
			<HR>
		<P>
			<!-- ======== NESTED CLASS SUMMARY ======== -->
			<!-- =========== FIELD SUMMARY =========== -->
			<A NAME="field_summary"><!-- --></A>
			<TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%">
				<TR BGCOLOR="#ccccff" CLASS="TableHeadingColor">
					<TD COLSPAN="2"><FONT SIZE="+2"> <B>Field Summary</B></FONT></TD>
				</TR>
				<TR BGCOLOR="white" CLASS="TableRowColor">
					<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static&nbsp;int</CODE></FONT></TD>
					<TD><CODE><B><A HREF="../../../javax/microedition/pim/Contact.html#ADDR">ADDR</A></B></CODE>
						<BR>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Field specifying an 
						address for this Contact.</TD>
				</TR>
				<TR BGCOLOR="white" CLASS="TableRowColor">
					<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static&nbsp;int</CODE></FONT></TD>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -