de.enough.polish.android.pim.enough
Class AbstractPIMList

java.lang.Object
  extended by de.enough.polish.android.pim.enough.AbstractPIMList
All Implemented Interfaces:
PIMList
Direct Known Subclasses:
ContactListImpl

public abstract class AbstractPIMList
extends Object
implements PIMList

This is an abstract class to unify common functionality of a PIMList

Author:
rickyn

Field Summary
 
Fields inherited from interface de.enough.polish.android.pim.PIMList
UNCATEGORIZED
 
Constructor Summary
AbstractPIMList(String name, int mode)
           
 
Method Summary
protected  void ensureListReadable()
          This method throws a SecurityException if the list is not readable.
protected  void ensureListWriteable()
           
 de.enough.polish.android.pim.enough.FieldInfo findFieldInfo(int fieldId)
           
 String getAttributeLabel(int attribute)
          Returns a String label associated with the given attribute.
 int getFieldDataType(int fieldId)
          Returns an int representing the data type of the data associated with the given field.
 String getFieldLabel(int fieldId)
          Returns a String label associated with the given field.
 String getName()
          Provides the name of the list.
 int[] getSupportedArrayElements(int stringArrayField)
          Returns an integer array containing all of the supported elements of a string array for the given field.
 int[] getSupportedAttributes(int field)
          Returns an integer array containing all of the supported attributes for the given field.
 int[] getSupportedFields()
          Gets all fields that are supported in this list.
 boolean isSupportedArrayElement(int stringArrayField, int arrayElement)
          Indicates whether or not the given element in a array is supported for the indicated field in this PIM list.
 boolean isSupportedAttribute(int field, int attribute)
          Indicates whether or not the given attribute is supported in this PIM list for the indicated field.
 boolean isSupportedField(int fieldId)
          Indicates whether or not the given field is supported in this PIM list.
 int maxValues(int field)
          Indicates the total number of data values that a particular field supports in this list.
protected  void setFieldInfos(de.enough.polish.android.pim.enough.FieldInfo[] fieldInfos)
          This method will set the fields this list can handle.
 int stringArraySize(int stringArrayField)
          Returns the size of the array for the given string array field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.enough.polish.android.pim.PIMList
addCategory, close, deleteCategory, getArrayElementLabel, getCategories, isCategory, items, items, items, itemsByCategory, maxCategories, renameCategory
 

Constructor Detail

AbstractPIMList

public AbstractPIMList(String name,
                       int mode)
Method Detail

findFieldInfo

public de.enough.polish.android.pim.enough.FieldInfo findFieldInfo(int fieldId)

getAttributeLabel

public String getAttributeLabel(int attribute)
Description copied from interface: PIMList
Returns a String label associated with the given attribute. Attribute labels are provided by the platform and are not changeable by the application.

isSupportedAttribute(int, int) should be used to verify the attribute's validity for this item prior to invoking this method.

Specified by:
getAttributeLabel in interface PIMList
Parameters:
attribute - - The attribute for which the label is being queried.
Returns:
String label for the attribute. The label is locale specific (see the microedition.locale system property).

getFieldDataType

public int getFieldDataType(int fieldId)
Description copied from interface: PIMList
Returns an int representing the data type of the data associated with the given field. This method is useful for platform extended fields. isSupportedField(int) should be used to verify the field validity for this item prior to invoking this method.

Specified by:
getFieldDataType in interface PIMList
Parameters:
fieldId - - The field for which the data type is being queried.
Returns:
int representing the type of the data associated with the field.

getFieldLabel

public String getFieldLabel(int fieldId)
Description copied from interface: PIMList
Returns a String label associated with the given field. Field labels are provided by the platform and are not changeable by the application.

isSupportedField(int) should be used to verify the field validity for this item prior to invoking this method.

Specified by:
getFieldLabel in interface PIMList
Parameters:
fieldId - - The field for which the label is being queried.
Returns:
String label for the field. The label is locale specific (see the microedition.locale system property).

getName

public String getName()
Description copied from interface: PIMList
Provides the name of the list. All PIMLists have a non-null name associated with it.

Specified by:
getName in interface PIMList
Returns:
a String representation of the list name.

getSupportedArrayElements

public int[] getSupportedArrayElements(int stringArrayField)
Description copied from interface: PIMList
Returns an integer array containing all of the supported elements of a string array for the given field. The array elements are provided one element per entry in the returned integer array.

Specified by:
getSupportedArrayElements in interface PIMList
Parameters:
stringArrayField - - the field to check
Returns:
an int array representing the supported array elements, one array element per entry in the array. If there are no supported array elements, a zero-length array is returned.

getSupportedAttributes

public int[] getSupportedAttributes(int field)
Description copied from interface: PIMList
Returns an integer array containing all of the supported attributes for the given field. All attributes supported by this list, including both standard and extended, are returned in this array. The attributes are provided one attribute per entry in the returned integer array.

Specified by:
getSupportedAttributes in interface PIMList
Parameters:
field - - the field to check
Returns:
an int array of the supported attributes, one attribute per entry in the array. If there are no supported fields, a zero-length array is returned.

getSupportedFields

public int[] getSupportedFields()
Description copied from interface: PIMList
Gets all fields that are supported in this list. All fields supported by this list, including both standard and extended, are returned in this array.

Specified by:
getSupportedFields in interface PIMList
Returns:
an int array containing all fields supported by this list. The order of the fields returned is unspecified. If there are no supported fields, a zero-length array is returned.

isSupportedArrayElement

public boolean isSupportedArrayElement(int stringArrayField,
                                       int arrayElement)
Description copied from interface: PIMList
Indicates whether or not the given element in a array is supported for the indicated field in this PIM list.

Specified by:
isSupportedArrayElement in interface PIMList
Parameters:
stringArrayField - - The field which has a STRING_ARRAY data type, as defined by classes implementing the PIMItem interface.
arrayElement - - The element in the array to check, as defined in the classes implementing the PIMItem interface.
Returns:
true if supported in this list, false otherwise. Invalid fields and invalid array elements return false.

isSupportedAttribute

public boolean isSupportedAttribute(int field,
                                    int attribute)
Description copied from interface: PIMList
Indicates whether or not the given attribute is supported in this PIM list for the indicated field.

Specified by:
isSupportedAttribute in interface PIMList
Parameters:
field - - The field against which the attribute is checked.
attribute - - The single attribute to check
Returns:
true if supported, false otherwise. Invalid fields and invalid attributes return false.

isSupportedField

public boolean isSupportedField(int fieldId)
Description copied from interface: PIMList
Indicates whether or not the given field is supported in this PIM list.

Specified by:
isSupportedField in interface PIMList
Parameters:
fieldId - - The field to check, as defined by in the class implementing the PIMItem.
Returns:
true if supported in this list, false otherwise. Invalid fields return false.

maxValues

public int maxValues(int field)
Description copied from interface: PIMList
Indicates the total number of data values that a particular field supports in this list.

Specified by:
maxValues in interface PIMList
Parameters:
field - - The field to check for multiple value support.
Returns:
int indicating the number of values that can be stored in the field. Additionally, -1 indicates this field supports having an unlimited number of added values in it, and 0 indicates the field is not supported by this list.

stringArraySize

public int stringArraySize(int stringArrayField)
Description copied from interface: PIMList
Returns the size of the array for the given string array field. Used for creating arrays for the string array field.

Specified by:
stringArraySize in interface PIMList
Parameters:
stringArrayField - - The string array field for which its array size is returned.
Returns:
int the size of the array of a single data instance of a string array field.

ensureListReadable

protected void ensureListReadable()
This method throws a SecurityException if the list is not readable. This is the case if the list was opened in WRITE_ONLY mode.


ensureListWriteable

protected void ensureListWriteable()

setFieldInfos

protected void setFieldInfos(de.enough.polish.android.pim.enough.FieldInfo[] fieldInfos)
This method will set the fields this list can handle.

Parameters:
fieldInfos -