📄 event.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<TITLE>Event (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.Event,Event interface">
<LINK REL="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
<SCRIPT>
function asd()
{
parent.document.title="Event (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> </TD>
<TD BGCOLOR="#eeeeff" CLASS="NavBarCell1">
<A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#ffffff" CLASS="NavBarCell1Rev">
<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#eeeeff" CLASS="NavBarCell1">
<A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#eeeeff" CLASS="NavBarCell1">
<A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#eeeeff" CLASS="NavBarCell1">
<A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#eeeeff" CLASS="NavBarCell1">
<A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </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"> <A HREF="../../../javax/microedition/pim/ContactList.html"><B>PREV
CLASS</B></A> <A HREF="../../../javax/microedition/pim/EventList.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> <A HREF="Event.html" TARGET="_top"><B>NO FRAMES</B></A>
<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: NESTED | <A HREF="#field_summary">FIELD</A> | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> DETAIL: <A HREF="#field_detail">FIELD</A> | CONSTR | <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 Event</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>Event</B><DT>extends <A HREF="../../../javax/microedition/pim/PIMItem.html">
PIMItem</A></DT></DL>
<P>
Represents a single Event entry in a PIM Event database. The fields are a
subset of the fields in the <code>vEvent</code> object defined by the vCalendar
1.0 specification from the Internet Mail Consortium (http://www.imc.org). The
subset represents those fields necessary to provide the relevant information
about an Event entry without compromising platform portability.
</P>
<P>
A single event may have multiple occurrences; i.e. the event may be a recurring
event that is repeated at specified intervals. Each occurrence of an event is
determined by using a <A HREF="../../../javax/microedition/pim/RepeatRule.html"><CODE>RepeatRule</CODE></A>
to calculate when the event should have additional occurrences, besides the one
defined by the <code>Event.START</code> field.
</P>
<P>The Event class has many different fields that it can support. However, each
individual Event object supports only fields valid for its associated list. Its
EventList restricts what fields in a Event are retained. This reflects that
some native Event databases do not support all of the fields available in a
Event 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#getSupportedFields()">
<CODE>PIMList.getSupportedFields()</CODE></A> can be used to determine if a
particular Event field is supported by an EventList and therefore persisted
when the Event is committed to its list. Attempts to set or get data based on
field IDs not supported in the Event's EventList result in a <A HREF="../../../javax/microedition/pim/UnsupportedFieldException.html">
<CODE>UnsupportedFieldException</CODE></A>.
</P>
<H3>Data</H3>
<P>The following table details the explicitly defined fields that may by in an
Event. Implementations may extend the field set using extended fields as
defined in PIMItem.
</P>
<h4>Table: Predefined Fields</h4>
<table border="1">
<TR>
<th>
Fields
</th>
<th>
Type of Data Associated with Field
</th>
</TR>
<tr>
<td><code>LOCATION, NOTE, SUMMARY, UID</code></td>
<td><code>PIMItem.STRING</code></td>
</tr>
<tr>
<td><code>END, REVISION, START </code>
</td>
<td><code>PIMItem.DATE</code></td>
</tr>
<tr>
<td><code>ALARM, CLASS</code></td>
<td><code>PIMItem.INT</code></td>
</tr>
</table>
<h3>Required Field Support</h3>
<P>All Event 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 Event 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 Event by the VM when the
Event 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 and type ID
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 Event.
<pre> EventList events = null;
try {
events = (EventList) PIM.getInstance().openPIMList(PIM.EVENT_LIST, PIM.READ_WRITE);
} catch (PIMException e) {
// An error occurred
return;
}
Event event = events.createEvent();
if (events.isSupportedField(Event.SUMMARY))
event.addString(Event.SUMMARY, PIMItem.ATTR_NONE, "Meeting with John");
if (events.isSupportedField(Event.START))
event.addDate(Event.START, PIMItem.ATTR_NONE, aDate.getTime());
if (events.isSupportedField(Event.END))
event.addDate(Event.END, PIMItem.ATTR_NONE, aDate.getTime());
if (events.isSupportedField(Event.ALARM))
event.addInt(Event.ALARM, PIMItem.ATTR_NONE, aDate.getTime() - 60000);
if (events.isSupportedField(Event.NOTE))
event.addString(Event.NOTE, PIMItem.ATTR_NONE, "I phoned on Monday to book this meeting");
if (events.maxCategories() != 0 && events.isCategory("Work"))
event.addToCategory("Work");
}
try {
event.commit();
} catch (PIMException e) {
// An error occured
}
try {
events.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 Event is rejected if any of the fields
are not supported in the particular list implementation.
<PRE> EventList events = null;
try {
events = (EventList) PIM.getInstance().openPIMList(PIM.EVENT_LIST, PIM.READ_WRITE);
} catch (PIMException e) {
// An error occurred
return;
}
Event event = events.createEvent();
try {
Date aDate = new Date();
event.addString(Event.SUMMARY, PIMItem.ATTR_NONE, "Meeting with John");
event.addDate(Event.START, PIMItem.ATTR_NONE, aDate.getTime());
event.addDate(Event.END, PIMItem.ATTR_NONE, aDate.getTime());
event.addDate(Event.ALARM, PIMItem.ATTR_NONE, aDate.getTime() - 60000);
event.addString(Event.NOTE, PIMItem.ATTR_NONE, "I phoned on Monday to book this meeting");
event.addToCategory("Work");
} 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("Event not saved");
return;
}
try {
event.commit();
} catch (PIMException e) {
// An error occured
}
try {
events.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/EventList.html">
<CODE>EventList</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 int</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../../javax/microedition/pim/Event.html#ALARM">ALARM</A></B></CODE>
<BR>
Field specifying a
relative time for an Alarm for this Event.</TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static int</CODE></FONT></TD>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -