Today’s mobile phone
is having all the features of a Personal Digital Assistant (PDA). But till
recently there was no way for a Java application to incorporate the
functionalities of a PDA in it. We could not access the contact information,
the calendar and scheduling information and even the file system. To eliminate
these difficulties the PDA Profile API’s were added. These API’s are optional
and hence are not there in many mobiles. But the day is not far when almost all
handsets will support this API.
javax.microedition.pim
One of the biggest
features a Personal Digital Assistant (PDA) sport’s is Personal Information
Management (PIM). There have been numerous instances when our clients have
requested us for applications that could use the personal information of the
user which already exists on his/her mobile. But unfortunately before the
introduction of this package we had to turn down there requests. Realizing the
great problems being faced by the J2ME developers the founders of J2ME have
introduced this package. These APIs have been defined in the JSR 75. One of the
biggest plus points of this package is that it can be made available on the
phone independent of the need for any particular configuration or profile. This
package helps us in using the calendar and contact data of the user that is
available on the phone. Now we will study this package in detail.
What is it?
The Contact interface represents a single
contact entry in the Personal Information Module Contact database. This interface
supports a subset of the fields defined by the vCard specification from the
Internet Mail Consortium (http://www.imc.org).
o Fields
- public static final int ADDR
This is
the field that specifies an address for the Contact.
·
public static final int BIRTHDAY
This is
the field that specifies the birthday of the Contact. The Data for this field
is in the same long value format as java.util.Date. To remind you the java.util.Date keeps time as
milliseconds since the epoch (00:00:00 GMT, January 1, 1970).
·
public static final int CLASS
This is
the field that specifies the desired access class for this contact.
·
public static final int EMAIL
This is
the field that specifies an e-mail address.
·
public static final int FORMATTED_ADDR
This is
the field that represents a formatted version of a complete address for the
Contact entry.
·
public static final int FORMATTED_NAME
This is
the field that represents a formatted version of a name for the Contact entry.
·
public static final int NAME
This is
the field that specifies the name for this contact.
·
public static final int NICKNAME
This is
the field that the data represents a nickname.
·
public static final int NOTE
This is
the field that specifies the supplemental information or a comment associated
with a Contact.
·
public static final int ORG
Field
specifying the organization name or units associated with a Contact.
·
public static final int PHOTO
This is
the field that specifies a photo for a Contact.
·
public static final int PHOTO_URL
This is
the field that specifies a photo of a Contact.
·
public static final int PUBLIC_KEY
This is
the field that specifies the public encryption key for a Contact.
·
public static final int PUBLIC_KEY_STRING
This is
the field that specifies the public encryption key for a Contact.
·
public static final int REVISION
This is
the field that specifies the last modification date and the time of a Contact
item.
·
public static final int TEL
This is
the field that stands for a voice telephone number.
·
public static final int TITLE
This is
the field that specifies the job title for a Contact.
·
public static final int UID
This is
the field that specifies a unique ID for a Contact.
·
public static final int URL
This is
the field that specifies the uniform resource locator for a Contact.
·
public static final int ATTR_ASST
This is
the attribute classifying a data value as related to an ASSISTANT.
·
public static final int ATTR_AUTO
This is
the attribute classifying a data value as related to AUTO.
·
public static final int ATTR_FAX
This is
the attribute classifying a data value as related to FAX.
·
public static final int ATTR_HOME
This is
the attribute classifying a data value as related to HOME.
·
public static final int ATTR_MOBILE
This is
the attribute classifying a data value as related to MOBILE.
·
public static final int ATTR_OTHER
This is
the attribute classifying a data value as "OTHER".
·
public static final int ATTR_PAGER
This is
the attribute classifying a data value as related to PAGER.
·
public static final int ATTR_PREFERRED
This is
the attribute classifying a data value with preferred status for retrieval or
display purposes (platform specific).
·
public static final int ATTR_SMS
This is
the attribute classifying a data value as related to SMS.
·
public static final int ATTR_WORK
This is
the attribute classifying a data value as related to WORK.
·
public static final int ADDR_POBOX
This field
defines an index into the string array for an address field, where the data at
this index represents the post office box of a particular address.
·
public static final int ADDR_EXTRA
This field
defines an index into the string array for an address field, where the data at
this index represents any extra info of a particular address.
·
public static final int ADDR_STREET
This field
defines an index into the string array for an address field, where the data at
this index represents the street information of a particular address.
·
public static final int ADDR_LOCALITY
This field
defines an 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.
·
public static final int ADDR_REGION
This field
defines an 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.
·
public static final int ADDR_POSTALCODE
This field
defines an 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.
·
public static final int ADDR_COUNTRY
This field
defines an index into the string array for an address field, where the data at
this index represents the country of a particular address.
·
public static final int NAME_FAMILY
This field
defines an index into the string array for a name field, where the data at this
index represents the family name. For example: “JAIN” or “GATES”.
·
public static final int NAME_GIVEN
This field
defines an index into the string array for a name field, where the data at this
index represents the given name. For example:
"Nagendra Kumar"
·
public static final int NAME_OTHER
This field
defines an index into the string array for a name field, where the data at this
index represents other alternate name or names. For example:
"SUPRIYA, PRIYA"
·
public static final int NAME_PREFIX
This field
defines an index into the string array for a name field, where the data at this
index represents a prefix to a name. For example:
"Mr."
·
public static final int NAME_SUFFIX
This field
defines an index into the string array for a name field, where the data at this
index represents a suffix to a name. For example:
"M.B.B.S"
·
public static final int CLASS_CONFIDENTIAL
This field
stands for a constant which indicates that this contact's class of access is
confidential.
·
public static final int CLASS_PRIVATE
This field
stands for a constant which indicates that this contact's class of access is
private.
·
public static final int CLASS_PUBLIC
This field
stands for a constant which indicates that this contact's class of access is
public.
o Methods
·
public int getPreferredIndex(int field)
This
method returns an integer representing the index of the value that is marked as
preferred.
public interface ContactList
What is it?
The ContactList
interface represents a Contact list containing Contact items.
o Fields
·
public static final java.lang.String UNCATEGORIZED
The field
is the constant for the itemsByCategory
(java.lang.String) method to indicate to search for uncategorized
items.
o Methods
·
public Contact createContact()
This
method returns a new empty Contact object associated with this list. The
Contact is not persistent in the list until a call to PIMItem.commit () for the
Contact is made.
·
public Contact importContact(Contact contact)
This
method returns a newly created Contact.
·
public void removeContact(Contact contact)throws
PIMException
This
method removes the specific Contact from the list.
public interface Event
What is it?
This interface represents
a single Event entry in a PIM Event database. The fields contained in this
interface are a subset of the fields in the vEvent object defined by the
vCalendar 1.0 specification from the Internet Mail Consortium
(http://www.imc.org).
o Fields
·
public static final int ALARM
This field
specifies a relative time for an Alarm for this Event.
·
public static final int CLASS
This field
specifies the desired access class for this contact. Data associated with this
field is of int type, and can be one of the values CLASS_PRIVATE, CLASS_PUBLIC,
or CLASS_CONFIDENTIAL.
·
public static final int END
This field
specifies the non-inclusive date and time a single Event ends. The Data for
this field is in the same long value format as java.util.Date. To remind you the java.util.Date keeps time
as milliseconds since the epoch (00:00:00 GMT, January 1, 1970).
·
public static final int LOCATION
This field
identifies the venue for this Event. The data for this field is in string
format. Example: "SKJ Mansion,
Delhi"
·
public static final int NOTE
This field
stands for a String specifying a more complete description than the SUMMARY for
this Event. The data for this field is in string format. For example:
"I have to meet Mr. Dell Today. I will talk to him regarding the issues we
are facing in selling our products."
·
public static final int REVISION
This field
specifies the last modification date and time of an Event item.
·
public static final int START
This field
specifies the inclusive date and time a single Event starts.
·
public static final int SUMMARY
This field
specifies the summary or subject for this Event. The data for this field is in
string format. For example: "Meeting with Mr. Dell"
·
public static final int UID
This field
specifies a unique ID for an Event. It can be used to check for identity using String.equals method.
·
public static final int CLASS_CONFIDENTIAL
This is
the constant indicating this event's class of access is confidential.
·
public static final int CLASS_PRIVATE
This is
the constant indicating this event's class of access is private.
·
public static final int CLASS_PUBLIC
This is
the constant indicating this event's class of access is public.
o Methods
·
public RepeatRule getRepeat()
This
method returns the RepeatRule describing how often this Event occurs or null if
a RepeatRule has not been set.
·
public void setRepeat(RepeatRule value)
This
method sets the RepeatRule specifying how often and when this event occurs.
public interface
EventList
What is it?
EventList represents
an event list containing event items.
o Fields
·
public static final int STARTING
This field
stands for a constant representing a search type for events based on the event
occurrence's specific start date/time.
·
public static final int ENDING
This field
stands for a constant representing a search type for events based on the event
occurrence's specific end date/time.
·
public static final int OCCURRING
This field
stands for a constant representing a search type for events based on any
occurrence of an event during a time period.
o Methods
·
public Event createEvent()
This
method returns a new empty Event object associated with this list. This Event onject
is not persistent in the list until a call to PIMItem.commit () for the Event
is made.
·
public Event importEvent(Event item)
This
method imports the given Event into this list by making a new Event for the
list and filling its information with as much information as it can from the
provided Event. In case the input Event already exists in the list, a new Event
is still created with information similar to the input item which may not
necessarily be identical.
·
public void removeEvent(Event item)throws
PIMException
This
method removes an already existing Event from the list.
·
public java.util.Enumeration items(int searchType,long startDate, long endDate,boolean initialEventOnly) throws PIMException
This
method returns an enumeration of all the Events with an occurrence between
startDate and endDate.
·
public int[] getSupportedRepeatRuleFields(int frequency)
This
method returns an array of integer values corresponding to the Repeat Rule
fields that are supported by this list for the given frequency.
public class
FieldEmptyException
What is it?
FieldEmptyException represents
an exception that is thrown when an attempt is made to access a field that does
not have any data values associated with it.
o Constructors
·
public FieldEmptyException()
This
constructor constructs a new instance of this class with its stack trace filled
in.
·
public FieldEmptyException(java.lang.String detailMessage)
This
constructor constructs a new instance of this class with its stack trace and
message filled in.
·
public FieldEmptyException(java.lang.String detailMessage,int field)
This
constructor constructs a new instance of this class with its stack trace,
message and offending field filled in.
o Methods
·
public int getField()
This
method returns int representing the offending field.
public class
FieldFullException
What is it?
FieldFullException represents
an exception that is thrown when an attempt is made to add data to a field but
the field already has all available slots for data values assigned.
o Conatroctor
·
public FieldFullException()
This
constructor constructs a new instance of this class with its stack trace filled
in.
·
public FieldFullException()
This
constructor constructs a new instance of this class with its stack trace filled
in.
·
public FieldFullException(java.lang.String detailMessage,int field)
This constructor
constructs a new instance of this class with its stack trace, message and
offending field filled in.
o Methods
·
public int getField()
This
method returns an int value representing the offending field.
public abstract class
PIM
What is it?
PIM class is the
class which helps us in accessing PIM lists on a device and performing functions
related to personal information management. PIM class consists of static
methods for getting the names of the existing PIM lists, opening the lists, and
converting raw data streams to and from PIM items for importing and exporting
into those lists.
o Constructors
·
protected PIM()
This constructor
is a constructor for subclasses. To get an instance of the PIM class we use the
getInstance method instead of the constructor.
o Fields
·
public static final int CONTACT_LIST
This field
stands for the constant representing a Contact List.
·
public static final int EVENT_LIST
This field
stands for the constant representing an Event List.
·
public static final int TODO_LIST
This field
stands for the constant representing a ToDo List.
·
public static final int READ_ONLY
This field
stands for the constant representing opening a list in read only mode.
·
public static final int WRITE_ONLY
This field
stands for the constant representing opening a list in write only mode.
·
public static final int READ_WRITE
This field
stands for the constant representing opening a list in read/write mode.
o Methods
·
public static PIM getInstance()
This
method returns an instance of the PIM class. This method is the method which is
normally used for getting an instance of this class.
·
public abstract PIMList openPIMList(int pimListType,int mode)throws
PIMException
This
method returns the default PIM list for the indicated PIM list type.
·
public abstract PIMList openPIMList(int pimListType, int mode,java.lang.String name)throws PIMException
This
method returns the named PIM list.
·
public abstract java.lang.String[] listPIMLists(int pimListType)
This
method returns a list of named PIM lists.
·
public abstract PIMItem[] fromSerialFormat(java.io.InputStream is, java.lang.String enc) throws
PIMException, java.io.UnsupportedEncodingException
This method creates and fills one or
more PIM items from data provided in the given InputStream object when the data
is expressed in a valid data format supported by this platform.
·
public abstract PIMItem[] fromSerialFormat(java.io.InputStream is, java.lang.String enc)throws PIMException,
java.io.UnsupportedEncodingException
This
method returns an array of newly created PIM items created from the
OutputStream.
·
public abstract void toSerialFormat(PIMItem item,
java.io.OutputStream os,java.lang.String enc,java.lang.String dataFormat)throws
PIMException,java.io.UnsupportedEncodingException
This
method writes the data from the given item to the given OutputStream object as
Unicode characters in a format indicated by the parameter.
·
public abstract java.lang.String[] supportedSerialFormats(int pimListType)
This
method returns String array of data formats supported for converting items to
and from data streams.
public class
PIMException
What is it?
PIMException represents
exceptions thrown by the PIM classes. PIMException class has a reason code
optionally associated with it. This reason code provides more information about
the PIM exception that occurred.
o Constructor
·
public PIMException()
This
constructor constructs a new instance of this class with its stack trace filled
in. The reason code for this exception is set to the default value of GENERAL_ERROR.
·
public PIMException(java.lang.String detailMessage)
This
constructor constructs a new instance of this class with its stacktrace and
message filled in.
·
public PIMException(java.lang.String detailMessage,int reason)
This
constructor constructs a new instance of this class with its stacktrace,
message and reason filled in.
o Fields
·
public static final int FEATURE_NOT_SUPPORTED
This field
indicates a PIM exception where the functionality is not supported in this
implementation.
·
public static final int GENERAL_ERROR
This field
indicates a general PIM exception error. This is the default value for the
reason code.
·
public static final int LIST_CLOSED
This field
indicates a PIM exception where a list is closed and access is attempted.
·
public static final int LIST_NOT_ACCESSIBLE
This field
indicates a PIM exception where a list is no longer accessible by the
application, such as if the underlying PIM database is deleted.
·
public static final int MAX_CATEGORIES_EXCEEDED
This field
indicates the max number of categories is exceeded.
·
public static final int UNSUPPORTED_VERSION
This field
indicates the data is in an unsupported PIM version.
·
public static final int UPDATE_ERROR
This field
indicates a PIM exception where the update could not continue.
o Methods
·
public int getReason()
This
method returns an int reason value for the exception.
public interface
PIMItem
What is it?
PIMItem represents
the common interfaces of an item for a PIM list. It represents a collection of
data for a single PIM entry.
o Fields
·
public static final int BINARY
This field
stands for a data type indicating data is binary in a byte array.
·
public static final int BOOLEAN
This field
stands for a data type indicating data is of boolean primitive data type.
·
public static final int DATE
This field
stands for a data type indicating data is a Date in long primitive data type
format expressed in the same long value format as java.util.Date.
·
public static final int INT
This field
stands for a data type indicating data is of int primitive data type.
·
public static final int STRING
This field
stands for a data type indicating data is a String object.
·
public static final int STRING_ARRAY
This field
stands for a data type indicating that data is an array of related fields
returned in a string array.
·
public static final int ATTR_NONE
This field
stands for a constant indicating that no additional attributes are applicable
to a data value for a field.
·
public static final int EXTENDED_FIELD_MIN_VALUE
This field
stands for a constant indicating the minimum possible value for an extended
field constant.
·
public static final int EXTENDED_ATTRIBUTE_MIN_VALUE
This field
stands for a constant indicating the minimum possible value for an extended
attribute constant.
o Methods
·
public PIMList getPIMList()
This
method returns the PIMList that this item belongs to. In case the item does not
belong to any list the null value is returned.
·
public void commit()throws
PIMException
This
method stores the data in the item to its PIM list.
·
public boolean isModified()
This
method returns the boolean value true if any fields have been modified since
the item was last retrieved or committed. It returns false otherwise.
·
public int[] getFields()
This
method returns int array of fields that have data currently stored for them. If
no fields contain data a zero length array is returned.
·
public byte[] getBinary(int field,int index)
This
method returns a byte array representing a value for the field. The value is an
inline binary data representation in a "B" binary encoded string as
defined by [IETF RFC 2047].
·
public void addBinary(int field,int attributes,byte[] value,offset,int length)
This
method adds a binary data value to a field in the item.
·
public void setBinary(int field,int index,int attributes,byte[] value, int offset,int length)
This
method sets an existing binary data value in a field to a new value.
·
public long getDate(int field,int index)
This method
gets a date value from a field in the item.
·
public void addDate(int field,int attributes,long value)
This
method adds a date value to a field in the item.
·
public void setDate(int field,int index,int attributes,long value)
This
method sets an existing date data value in a field to a new value.
·
public int getInt(int field,int index)
This
method returns an int representing a value of the field.
·
public void addInt(int field,int attributes,int value)
This
method adds an integer value to a field in the item.
·
public void setInt(int field,int index,int attributes,int value)
This
method sets an existing int data value in a field to a new value.
·
public java.lang.String getString(int field,int index)
This
method returns a String representing a value of the field. A null String (String
s “”) may also be returned by this method.
·
public void addString(int field,int attributes,java.lang.String value)
This
method adds a String value to a field in the item.
·
public void setString(int field,int index,int attributes,java.lang.String value)
This
method sets an existing String data value in a field to a new value.
·
public boolean getBoolean(int field,int index)
This
method returns a boolean representing a value of the field.
·
public void addBoolean(int field,int attributes,boolean value)
This
method adds a boolean value to a field in the item.
·
public void setBoolean(int field,int index,int attributes,
boolean value)
This
method sets an existing boolean data value in a field to a new value.
·
public java.lang.String[] getStringArray(int field,int index)
This
method returns a String array representing a group of related values from the
field.
·
public void addStringArray(int field,nt attributes,java.lang.String[] value)
This
method adds an array of related string values as a single entity to a field in
the item.
·
public void setStringArray(int field,int index,int attributes, java.lang.String[] value)
This
method sets an existing String array data value in a field to a new value.
·
public int countValues(int field)
This
method returns int indicating the number of values currently assigned to the
field in this item.
·
public void removeValue(int field,int index)
This
method removes the value at the given index for the indicated field in this
item.
·
public int getAttributes(int field,int index)
This
method returns int representing the attributes assigned to the value at the
given field and index.
·
public void addToCategory(java.lang.String category)throws
PIMException
This
method adds a category to this item.
·
public void removeFromCategory(java.lang.String category)
This
method removes a category from this item
·
public java.lang.String[] getCategories()
This
method returns a string array of all the categories for the item.
·
public int maxCategories()
This
method returns the maximum number of categories that this item can be assigned
to.
public interface
PIMList
What is it?
PIMList represents
the common functionality of a PIM list. It contains 0 or more PIMItems
(represented by the class PIMItem).
It also allows retrieval of all or some of the PIMItems contained in the list.
o Field
·
public static final java.lang.String UNCATEGORIZED
This field
is the constant for the itemsByCategory(java.lang.String)
method to indicate to search for uncategorized items.
o Methods
·
public java.lang.String getName()
This
method returns a String representation of the list name.
·
public void close()throws PIMException
This
method closes the list. In doing so it also releases any resources for this
list. A PIMException is thrown for any subsequent method invocations for the
class instance.
·
public java.util.Enumeration items()throws
PIMException
This
method returns an enumeration of all items.
·
public java.util.Enumeration items(PIMItem matchingItem)throws
PIMException
This
method returns an enumeration of all items that contains fields that match all
of the fields of the item parameter.
·
public java.util.Enumeration items(java.lang.String matchingValue)throws
PIMException
This
method returns an enumeration of all items that contain at least one field that
matches the string parameter.
·
public java.util.Enumeration itemsByCategory(java.lang.String category)throws
PIMException
This
method returns an enumeration of all items in the PIM list that match the
category.
·
public java.lang.String[] getCategories()throws
PIMException
This
method returns a string array containing the categories defined for the PIM
list.
·
public boolean isCategory(java.lang.String category)throws
PIMException
This
method returns true if the category indicated is a valid existing category for
this list. Else it returns false.
·
public void addCategory(java.lang.String category)throws
PIMException
This
method adds a category to this item.
·
public void deleteCategory(java.lang.String category,boolean deleteUnassignedItems)
throws PIMException
This
method deletes the indicated category from the PIM list. In case the indicated
category is not in the PIM list, this method successfully compeletes.
·
public void renameCategory(java.lang.String currentCategory, java.lang.String newCategory)throws
PIMException
This
method renames a category from an old name to a new name.
·
public int maxCategories()
This
method returns an int value indicating the number of categories supported by
this list. 0 indicates that no category is supported and -1 indicates there is
no limit to the number of categories that this list can have.
·
public boolean isSupportedField(int field)
This
method returns true if the field is supported in this list else it will return
false.
·
public int[] getSupportedFields()
This
method returns an int array containing all fields supported by this list.
·
public boolean isSupportedAttribute(int field,int attribute)
This
method returns a true value if attribute is supported for a given field. It
returns false otherwise. Invalid values for fields and attributes will also return
false.
·
public int[] getSupportedAttributes(int field)
This
method returns an int array of the supported attributes. There will be one
attribute per entry in the array. In case there are no supported fields a
zero-length array will be returned.
·
public boolean isSupportedArrayElement(int stringArrayField, int arrayElement)
This
method returns true if supported in this list otherwise it returns false.
Invalid fields and invalid array elements will also return false.
·
public int[] getSupportedArrayElements(int stringArrayField)
This
method returns an int array representing the supported array elements. There
will be one array element per entry in the array. In case there are no
supported array elements a zero-length array will be returned.
·
public int getFieldDataType(int field)
This
method returns int representing the type of the data associated with the field.
·
public java.lang.String getFieldLabel(int field)
This
method returns String label for the field.
·
public java.lang.String getAttributeLabel(int attribute)
This
method returns String label for the attribute.
·
public java.lang.String getArrayElementLabel(int stringArrayField, int arrayElement)
This
method returns String label for the array element.
·
public int maxValues(int field)
This
method returns int value indicating the number of values that can be stored in
the field. A value of -1 indicates that this field supports having an unlimited
number of added values. Zero indicates the field is not supported by this list.
·
public int stringArraySize(int stringArrayField)
This
method returns int the size of the array of a single data instance of a string
array field.
public class
RepeatRule
What is it?
RepeatRule class represents
a description for a repeating pattern for an Event item. The fields contained
in this class are a subset of the capabilities of the RRULE field in VEVENT
defined by the vCalendar 1.0 specification from the Internet Mail Consortium
(http://www.imc.org). This class is use to determine how often an associated
Event occurs.
o Constructor
·
public RepeatRule()
This
method is a default constructor.
o Fields
·
public static final int FREQUENCY
This field
specifies the frequency of the Repeat.
·
public static final int DAY_IN_MONTH
This field
specifies the day of the month an Event occurs; for example, 15.
·
public static final int DAY_IN_WEEK
This field
specifies the day of the week an Event occurs.
·
public static final int DAY_IN_YEAR
This field
specifies the day of the year an Event occurs; for example, 134
·
public static final int MONTH_IN_YEAR
This field
specifies the month in which an event occurs.
·
public static final int WEEK_IN_MONTH
This field
specifies which week in a month a particular event occurs.
·
public static final int COUNT
This field
specifies the number of times this event repeats including the first time,
starting from the first time the event starts (derived from Event.START) and
continuing to the last date of the repeat (defined by RepeatRule.END).
·
public static final int END
This field
specifies the ending date of the repeating event. Data for this field is
expressed in the same long value format as java.util.Date.
·
public static final int INTERVAL
This field
specifies the number of iterations of the frequency between occurring dates
i.e. how often the frequency repeats.
·
public static final int DAILY
This field
specifies the frequency when the Event happens every day.
·
public static final int WEEKLY
This field
specifies the frequency when the Event happens every week.
·
public static final int MONTHLY
This field
specifies the frequency when the Event happens every month.
·
public static final int YEARLY
This field
specifies the frequency when the Event happens every year.
·
public static final int FIRST
This field
specifies constant for the first week of the month used with WEEK_OF_MONTH
field.
·
public static final int SECOND
This field
specifies constant for the second week of the month used with WEEK_OF_MONTH
field.
·
public static final int THIRD
This field
specifies constant for the third week of the month used with WEEK_OF_MONTH
field.
·
public static final int FOURTH
This field
specifies constant for the fourth week of the month used with WEEK_OF_MONTH
field.
·
public static final int FIFTH
This field
specifies constant for the fifth week of the month used with WEEK_OF_MONTH
field.
·
public static final int LAST
This field
specifies constant for the last week of the month used with WEEK_OF_MONTH field.
·
public static final int SECONDLAST
This field
specifies constant for the second to last week of the month used with WEEK_OF_MONTH
field.
·
public static final int THIRDLAST
This field
specifies constant for the third to last week of the month used with WEEK_OF_MONTH
field.
·
public static final int FOURTHLAST
This field
specifies constant for the fourth to last week of the month used with WEEK_OF_MONTH
field.
·
public static final int FIFTHLAST
This field
specifies constant for the fifth to last week of the month used with WEEK_OF_MONTH
field.
·
public static final int SATURDAY
This field
specifies constant for the day of week Saturday used with DAY_IN_WEEK field.
·
public static final int FRIDAY
This field
specifies constant for the day of week Friday used with DAY_IN_WEEK field.
·
public static final int THURSDAY
This field
specifies constant for the day of week Thursday used with DAY_IN_WEEK field.
·
public static final int WEDNESDAY
This field
specifies constant for the day of week Wednesday used with DAY_IN_WEEK field.
·
public static final int TUESDAY
This field
specifies constant for the day of week Tuesday used with DAY_IN_WEEK field.
·
public static final int MONDAY
This field
specifies constant for the day of week Monday used with DAY_IN_WEEK field.
·
public static final int SUNDAY
This field
specifies constant for the day of week Sunday used with DAY_IN_WEEK field.
·
public static final int JANUARY
This field
specifies constant for the month of January used with MONTH_IN_YEAR field.
·
public static final int FEBRUARY
This field
specifies constant for the month of February used with MONTH_IN_YEAR field.
·
public static final int MARCH
This field
specifies constant for the month of March used with MONTH_IN_YEAR field.
·
public static final int APRIL
This field
specifies constant for the month of April used with MONTH_IN_YEAR field.
·
public static final int MAY
This field
specifies constant for the month of May used with MONTH_IN_YEAR field.
·
public static final int JUNE
This field
specifies constant for the month of June used with MONTH_IN_YEAR field.
·
public static final int JULY
This field
specifies constant for the month of July used with MONTH_IN_YEAR field.
·
public static final int AUGUST
This field
specifies constant for the month of August used with MONTH_IN_YEAR field.
·
public static final int SEPTEMBER
This field
specifies constant for the month of September used with MONTH_IN_YEAR field.
·
public static final int OCTOBER
This field
specifies constant for the month of October used with MONTH_IN_YEAR field.
·
public static final int NOVEMBER
This field
specifies constant for the month of November used with MONTH_IN_YEAR field.
·
public static final int DECEMBER
This field
specifies constant for the month of December used with MONTH_IN_YEAR field.
o Methods
·
public java.util.Enumeration dates(long startDate,long subsetBeginning,
long subsetEnding)
This
method returns an Enumeration of dates for the given parameters with the
Enumeration containing java.util.Date instances.
·
public void addExceptDate(long date)
This
method adds a Date for which this RepeatRule should not occur.
·
public void removeExceptDate(long date)
This
method removes a Date for which this RepeatRule should not occur.
·
public java.util.Enumeration getExceptDates()
This
method returns an Enumeration of dates for which this RepeatRule should not
occur. The Enumeration contains the java.util.Date instances.
·
public int getInt(int field)
This
method returns an int representing the value of the field.
·
public void setInt(int field,int value)
This
method sets an integer field. The field value can be one of the following:
COUNT,
DAYNUMBER, FREQUENCY, INTERVAL, MONTH_IN_YEAR,
WEEK_IN_MONTH, DAY_IN_WEEK, DAY_IN_YEAR.
·
public long getDate(int field)
This
method returns a Date representing the value of the field expressed in the same
long value format as java.util.Date.
·
public void setDate(int field,long value)
This
method sets a Date field.
·
public int[] getFields()
This
method returns an array of fields that have values currently assigned to them.
If no fields have values set an array of zero length is returned by this method.
·
public boolean equals(java.lang.Object obj)
This
method returns true if the contents of the RepeatRules are equivalent.
Otherwise this method returns false.
public interface ToDo
What is it?
This interface represents a single To Do
item in a PIM To Do database. The fields in this interface are a subset of the
fields in VTODO defined by the vCalendar specification from the Internet Mail
Consortium (http://www.imc.org).
o Fields
·
public static final int CLASS
This field
specifies the desired access class for this contact.
·
public static final int COMPLETED
This field
specifies the ID indicating a ToDo has been completed. Data for this field is
in boolean format.
·
public static final int COMPLETION_DATE
This field
specifies the ID indicating a ToDo has been completed on the date indicated by
this field.
·
public static final int DUE
This field
specifies the date a ToDo is due.The data for this field is expressed in the
same long value format as java.util.Date.
·
public static final int NOTE
This field
specifies a more complete description than the SUMMARY for this ToDo. Data for
this field is in string format. For example:
"Priyanka really likes stained glass and expensive pens"
·
public static final int PRIORITY
This field
specifies the priority of this ToDo. The priority is a value from 0 to 9.
·
public static final int REVISION
This field
specifies the last modification date and time of a ToDo item.
·
public static final int SUMMARY
This field
specifies the summary or subject for this ToDo.
·
public static final int UID
This field
specifies a unique ID for a ToDo. This field can be used to check for identity
using the String.equals method.
·
public static final int CLASS_CONFIDENTIAL
This field
specifies a constant indicating this todo's class of access is confidential.
·
public static final int CLASS_PRIVATE
This field
specifies a constant indicating this todo's class of access is private.
·
public static final int CLASS_PUBLIC
This field
specifies a constant indicating this todo's class of access is public.
public interface
ToDoList
What is ti?
This interface represents
a ToDo list containing ToDo items.
o Methods
·
public ToDo createToDo()
This
method returns a new empty ToDo object associated with this list. The ToDo is
still not persistent in the list until a call to PIMItem.commit () for the ToDo
is made.
·
public ToDo importToDo(ToDo item)
This
method returns a newly created ToDo item.
·
public void removeToDo(ToDo item)throws
PIMException
This method
removes a specific ToDo from the list. The item must already exist in the list
for this method to be succesful.
·
public java.util.Enumeration items(int field,long startDate,long endDate)throws
PIMException
This
method returns an enumeration of all the ToDos with specified date field
between startDate and endDate
public class
UnsupportedFieldException
What is it?
This exception represents
an exception thrown when a field is referenced that is not supported in the
particular PIM list that an element belongs to.
o Constructors
·
public UnsupportedFieldException()
This
constructor constructs a new instance of this class with its stack trace filled
in.
·
public UnsupportedFieldException(java.lang.String detailMessage)
This
constructor constructs a new instance of this class with its stack trace and
message filled in.
·
public UnsupportedFieldException(java.lang.String detailMessage,int field)
This
constructor constructs a new instance of this class with its stack trace,
message and offending field filled in.
o Methods
·
public int getField()
This
method returns int value representing the offending field.
javax.microedition.io.file
One of the great
problems faced by us programmers within the MIDP environment was that it was
not possible to access the native file system. This posed many challenges to us
programmers. Heading to the industry demand for an API for accessing file
system finally the founders of J2ME have defined an API for file management in
the JSR 75. This is an optional API. One of the biggest plus points of this
package is that it can be made available on the phone independent of the need
for any particular configuration or profile.
public class
ConnectionClosedException
What is it?
This exception represents
an exception thrown when a method is invoked on a file connection but the
method cannot be completed because the connection is closed.
o Constructors
- public ConnectionClosedException()
This
construction constructs a new instance of this class with its stack trace filled
in.
·
public ConnectionClosedException(java.lang.String detailMessage)
This
construction constructs a new instance of this class with its stack trace and
message filled in.
public interface
FileConnection
What is it?
FileConnection
interface is intended to access files or directories that are located on
removeable media and/or file systems on a device. Device’s internal filesystems
in memory may also be accessed through this class as well if there is
underlying hardware and operating system support. If the file connections are
not supported to a particular media or file system then the attempts to open a
file connection to that particular media or file system through Connector.open() results
in an javax.microedition.io.IOException
being thrown.
o Methods
This
method returns true if the file connection is open else it returns false.
·
public java.io.InputStream openInputStream()throws
java.io.IOException
This
method opens an input stream.
·
public java.io.DataInputStream openDataInputStream() throws java.io.IOException
This
method opens a DataInputStream.
·
public java.io.OutputStream openOutputStream()throws
java.io.IOException
This
method opens an output stream.
·
public java.io.DataOutputStream openDataOutputStream() throws java.io.IOException
This
method opens a DataOutputStream.
·
public java.io.OutputStream openOutputStream(long byteOffset) throws
java.io.IOException
This
method returns an OutputStream positioned at the byte offset in the file or the
end of the file if the offset is greater than the size of the file.
·
public long totalSize()
This
method returns the total size of the file system in bytes. It returns -1 if the
file system is not accessible.
·
public long availableSize()
This
method returns the available size in bytes on a file system. It returns -1 if
the file system is not accessible.
·
public long usedSize()
This
method returns the used size of bytes on a file system. It returns -1 if the
file system is not accessible.
·
public long directorySize(boolean includeSubDirs)throws
java.io.IOException
This
method returns the size in bytes occupied by the files included in the
directory. It returns -1 if the directory does not exist or is not accessible.
·
public long fileSize() throws
java.io.IOException
This
method returns the size in bytes of the selected file. It returns -1 if the
file does not exist or is not accessible.
·
public boolean canRead()
This
method returns true if the connection's target exists, it is accessible and it
is readable. Else it will return false.
·
public boolean canWrite()
This
method returns true if the connection's target exists, it is accessible and it
is writable. Else it will return false.
·
public boolean isHidden()
This
method returns true if the file exists, it is accessible and it is hidden. Else
it will return false.
·
public void setReadable(boolean readable)throws
java.io.IOException
This
method sets the file or directory readable attribute to the indicated value.
·
public void setWritable(boolean writable)throws
java.io.IOException
This
method sets the selected file or directory writable attribute to the indicated
value.
·
public void setHidden(boolean hidden)throws
java.io.IOException
This method
sets the hidden attribute of the selected file to the value provided.
·
public java.util.Enumeration list()throws
java.io.IOException
This
method returns an Enumeration of strings denoting the files and directories in
the directory.
·
public java.util.Enumeration list(java.lang.String filter,boolean includeHidden) throws
java.io.IOException
This
method returns an Enumeration of strings denoting the files and directories in
the directory matching the filter.
·
public void create()throws
java.io.IOException
This
method creates a file corresponding to the file string provided in the Connector.open
() method for this FileConnection.
·
public void mkdir()throws
java.io.IOException
This
method creates a directory corresponding to the directory string provided in
the Connector.open () method.
·
public boolean exists()
This
method returns true if the connnection's target exists and is accessible,
otherwise false.
·
public boolean isDirectory()
This
method returns true if the connection's target exists, it is accessible and it
is a directory. Else it returns false.
·
public void delete()throws
java.io.IOException
This
method deletes the file or directory specified in the Connector.open() URL.
·
public void rename(java.lang.String newName)throws
java.io.IOException
This
method renames the selected file or directory to a new name in the same
directory.
·
public void truncate(long byteOffset)throws
java.io.IOException
This
method truncates the file, discarding all data from the given byte offset to
the current end of the file.
·
public void setFileConnection(java.lang.String fileName)throws
java.io.IOException
This
method resets this FileConnection object to another file or directory.
·
public java.lang.String getName()
This
method returns the name of a file or directory excluding the URL schema and all
paths.
·
public java.lang.String getPath()
This
method returns the path excluding the file or directory name and the
"file" URL schema and host from where the file or directory specified
in the Connector.open() method is opened.
·
public java.lang.String getURL()
This
method returns the full file URL including the scheme, host, and path from
where the file or directory specified in the Connector.open() method is opened.
·
public long lastModified()
This
method returns the time that the file denoted by the URL specified in the
Connector.open () method was last modified.
public interface
FileSystemListener
What is it?
FileSystemListener
class is used for receiving status notification when adding or removing a file
system root. This situation arises when a card is inserted or removed from a
device or when a file system is mounted or unmounted to a device.
o Fields
- public static final int ROOT_ADDED
This field
stands for a constant indicating that a file system root has been added to the
device.
·
public static final int ROOT_REMOVED
This field
stands for a constant indicating that a file system root has been removed from
the device.
o Methods
- public void rootChanged(int state,java.lang.String rootName)
This
method is invoked when a root on the device has changed state.
public class
FileSystemRegistry
What is it?
This class is a
central registry for file system listeners interested in the adding and
removing, mounting and unmounting of file systems on a device.
o Methods
- public static boolean addFileSystemListener(FileSystemListener listener)
This
method returns a boolean value indicating if file system listener was
successfully added or not.
·
public static boolean removeFileSystemListener(FileSystemListener listener)
This method
returns a boolean value indicating if file system listener was successfully
removed or not.
·
public static java.util.Enumeration listRoots()
This
method returns an Enumeration of mounted file systems as String objects.
public class
IllegalModeException
What is it?
This exception represents
an exception thrown when a method is invoked requiring a particular security
mode (e.g. READ or WRITE) but the connection opened is not in the mode
required.
o Constructors
- public IllegalModeException()
This
constructor constructs a new instance of this class with its stack trace filled
in.
·
public IllegalModeException(java.lang.String detailMessage)
This constructor constructs
a new instance of this class with its stack trace and message filled in.
Back | Next