Java Reference
In-Depth Information
Reading Records from a PIM Database
With the
PIMList
in hand for the PIM database you want to access, you can obtain an
Enumeration
of its contents, returned as
PIMItem
objects. You may use one of three
items
methods to obtain an
Enumeration
:
• An
items
method that takes no arguments and returns an
Enumeration
of
all
items
in the database
• An
items
method that takes a
String
and returns an
Enumeration
containing only
those records whose
String
fields contain the
String
you passed to
items
• An
items
method that takes a
PIMItem
template and returns an
Enumeration
contain-
ing only those records whose fields contain the fields you specified in the template
item (which, of course, must be a
ContactItem
,
EventItem
, or
ToDoItem
, matching the
type of
PIMList
you're querying)
These
items
methods can throw one of the following exceptions:
•
IllegalArgumentException
: If the arguments are malformed
•
PIMException
: If an error is manipulating the
PIMList
•
SecurityException
: If the application is not permitted to access the PIM database
Reading Fields from a PIM Record
The
PIMItem
interface is a generic interface into multiple types of record data: a
contact, an event, or a to-do. Consequently, the
PIMItem
uses the notion of
field keys
to access a given datum in a
PIMItem
such as a contact's first name or an event's start
time. These fields are defined by well-defined standards such as the vCard specifica-
tion from the Internet Mail Consortium. Each of the various
PIMItem
interface sub-
classes defines constant integer accessor keys indicating field types that a
PIMItem
can
return in response to an accessor interface. Table 7-1 shows the accessor field keys
defined by the PIM package.