Methods Summary |
---|
public void | addCategory(java.lang.Object listHandle, java.lang.String category)Adds a category to the categories defined for a list.
initialize();
String cats = database.getCategories(((List)listHandle).type,
((List)listHandle).name);
// the implementation expects that '\n' is never escaped in categories
String cat_add = "\n" + category;
if (cats.indexOf(cat_add + '\n") != -1 ||
cats.startsWith(category + '\n") ||
cats.endsWith(cat_add) ||
((cats.length() > 0) && cats.equals(category))) {
return;
}
if (cats.length() == 0 && category.length() > 0) {
cats = category;
} else {
cats += cat_add;
}
database.setCategories(((List)listHandle).type,
((List)listHandle).name, cats);
|
public void | closeList(java.lang.Object listHandle)Closes list.
|
public synchronized java.lang.Object | commitListElement(java.lang.Object listHandle, java.lang.Object elementKey, byte[] element, java.lang.String[] categories)Commit a list element.
initialize();
elementKey = database.commitElement(((List)listHandle).type,
((List)listHandle).name, (String)elementKey, element);
return elementKey;
|
public void | deleteCategory(java.lang.Object listHandle, java.lang.String category)Deletes a category from the categories defined for a list.
initialize();
String cats = database.getCategories(((List)listHandle).type,
((List)listHandle).name);
// the implementation expects that '\n' is never escaped in categories
String cat_add = "\n" + category;
int pos;
if ((pos = cats.indexOf(cat_add + '\n")) != -1) {
cats = cats.substring(0, pos)
+ cats.substring(pos + cat_add.length());
} else if (cats.startsWith(category + '\n")) {
cats = cats.substring(cat_add.length());
} else if (cats.endsWith(cat_add)) {
cats = cats.substring(0, cats.length() - cat_add.length());
} else if (cats.equals(category)) {
cats = "";
} else {
return;
}
database.setCategories(((List)listHandle).type,
((List)listHandle).name, cats);
|
public java.lang.String | getArrayElementLabel(java.lang.Object listHandle, int field, int arrayElement)Gets the array element label.
initialize();
return getFieldDescriptor(((List)listHandle).type, field)
.getElementlabel(arrayElement);
|
public java.lang.String | getAttributeLabel(java.lang.Object listHandle, int attribute)Gets attribute label for the given field attribute.
initialize();
StringBuffer tag = new StringBuffer("PIM.Attributes.");
if (attribute == 0) {
tag.append("None");
} else {
switch (((List)listHandle).type) {
case CONTACT_LIST: tag.append("ContactList."); break;
case EVENT_LIST: tag.append("EventList."); break;
case TODO_LIST: tag.append("ToDoList."); break;
default: return null;
}
int index = 0;
while (attribute > 1) {
index++;
attribute = attribute >> 1;
}
tag.append(index);
}
String tagString = tag.toString();
String returnValue = Configuration.getPropertyDefault(tagString,
"Label_" + tagString);
return returnValue;
|
public java.lang.String[] | getCategories(java.lang.Object listHandle)Gets the set of categories defined for a list.
initialize();
String result = database.getCategories(((List)listHandle).type,
((List)listHandle).name);
return FormatSupport.split(result, '\n", 0);
|
public byte[] | getDefaultBinaryValue(java.lang.Object listHandle, int field)Gets the default byte[] value for the given field. This will
only
return a valid value if hasDefaultValue(listType, field) returns true.
return null;
|
public boolean | getDefaultBooleanValue(java.lang.Object listHandle, int field)Gets the default boolean value for the given field. This will
only
return a valid value if hasDefaultValue(listType, field) returns true.
return false;
|
public long | getDefaultDateValue(java.lang.Object listHandle, int field)Gets the default date value for the given field. This will only
return a valid value if hasDefaultValue(listType, field) returns true.
return 0;
|
public int | getDefaultIntValue(java.lang.Object listHandle, int field)Gets the default integer value for the given field. This will
only
return a valid value if hasDefaultValue(listType, field) returns true.
initialize();
PIMFieldDescriptor descriptor =
getFieldDescriptor(((List)listHandle).type, field);
return ((Integer) descriptor.getDefaultValue()).intValue();
|
public java.lang.String | getDefaultListName(int listType)Get the name of the default list for the given type.
initialize();
return database.getDefaultListName(listType);
|
public java.lang.String[] | getDefaultStringArrayValue(java.lang.Object listHandle, int field)Gets the default String[] value for the given field. This will
only
return a valid value if hasDefaultValue(listType, field) returns true.
int length = getStringArraySize(listHandle, field);
return new String[length];
|
public java.lang.String | getDefaultStringValue(java.lang.Object listHandle, int field)Gets the default string value for the given field. This will
only
return a valid value if hasDefaultValue(listType, field) returns true.
return null;
|
public int | getFieldDataType(java.lang.Object listHandle, int field)Gets the data type of the field.
initialize();
try {
return getFieldDescriptor(((List)listHandle).type, field)
.getDataType();
} catch (NullPointerException npe) {
return -1;
}
|
private PIMFieldDescriptor | getFieldDescriptor(int listType, int field)Gets the descriptor for given field.
return (PIMFieldDescriptor)getFields(listType).get(new Integer(field));
|
public java.lang.String | getFieldLabel(java.lang.Object listHandle, int field)Gets the label of the field.
initialize();
try {
return getFieldDescriptor(((List)listHandle).type, field)
.getLabel();
} catch (NullPointerException npe) {
return null;
}
|
private java.util.Hashtable | getFields(int listType)Gets the table of fields for given list type.
Hashtable map;
switch (listType) {
case CONTACT_LIST:
map = contactListFields;
break;
case EVENT_LIST:
map = eventListFields;
break;
case TODO_LIST:
map = todoListFields;
break;
default:
throw new IllegalArgumentException("List type " + listType
+ " is not valid");
}
return map;
|
public byte[] | getListElement(java.lang.Object listHandle, java.lang.Object elementKey)Get the data for a list element.
initialize();
return database.getElement(((List)listHandle).type,
((List)listHandle).name, (String)elementKey);
|
public java.lang.String[] | getListElementCategories(java.lang.Object listHandle, java.lang.Object elementKey)Get categories for the specified list element.
return new String[0];
|
public synchronized java.lang.Object[] | getListKeys(java.lang.Object listHandle)Get list element keys.
initialize();
Hashtable hash_keys =
database.getKeys(((List)listHandle).type, ((List)listHandle).name);
int len = hash_keys.size();
Object[] keys = new Object[len];
Enumeration en_keys = hash_keys.keys();
for (int i = 0; i < len; i++) {
keys[i] = en_keys.nextElement().toString();
}
return keys;
|
public synchronized java.lang.String[] | getListNames(int listType)Get the supported list names for the given list type. All list elements
must be unique within the list.
initialize();
int length = database.getListNames(listType).length;
String[] names = new String[length];
for (int i = 0; i < length; i++) {
names[i] = database.getListNames(listType)[i];
}
return names;
|
public int | getMaximumValues(java.lang.Object listHandle, int field)Get the maximum number of values that can be stored in the given field.
initialize();
return getFieldDescriptor(((List)listHandle).type, field)
.getMaximumValues();
|
public int | getStringArraySize(java.lang.Object listHandle, int field)Checks if size of the string array.
initialize();
try {
return getFieldDescriptor(((List)listHandle).type, field)
.getStringArraySize();
} catch (NullPointerException npe) {
// debug.exception(Debug.LIGHT, npe);
return 0;
}
|
public int[] | getSupportedArrayElements(java.lang.Object listHandle, int field)Gets the array of supported elements.
int size = getStringArraySize(listHandle, field);
int[] result = new int[size];
for (int i = 0; i < size; i++) {
result[i] = i;
}
return result;
|
public int[] | getSupportedAttributes(java.lang.Object listHandle, int field)Gets the supported attributes for the given field.
initialize();
int listType = ((List)listHandle).type;
long attributes = getFieldDescriptor(listType, field)
.getSupportedAttributes();
int elementCount = listType == PIM.CONTACT_LIST ? 1 : 0;
for (long a = attributes; a > 0; a >>= 1) {
if ((a & 1) == 1) {
elementCount++;
}
}
int[] result = new int[elementCount];
if (elementCount > 0) {
int a = 1;
int i;
if (listType == PIM.CONTACT_LIST) {
result[0] = PIMItem.ATTR_NONE;
i = 1;
} else {
i = 0;
}
for (; i < elementCount; i++) {
while ((attributes & a) == 0) a <<= 1;
result[i] = a;
a <<= 1;
}
}
return result;
|
public int | getSupportedAttributesMask(java.lang.Object listHandle, int field)Gets a mask containing all possible attributes for the given field.
initialize();
return (int)getFieldDescriptor(((List)listHandle).type, field)
.getSupportedAttributes();
|
public int[] | getSupportedFields(java.lang.Object listHandle)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.
initialize();
Hashtable map = getFields(((List)listHandle).type);
Enumeration fieldNumbers = map.keys();
int len = map.size();
int[] result = new int[len];
for (int i = 0; i < len; i++) {
result[i] = (fieldNumbers.nextElement()).hashCode();
}
return result;
|
public boolean | hasDefaultValue(java.lang.Object listHandle, int field)Checks if field has default value.
initialize();
return getFieldDescriptor(((List)listHandle).type, field)
.hasDefaultValue();
|
public synchronized void | initialize()Set up data structures.
if (!initialized) {
initializeMap(contactListFields,
SupportedPIMFields.CONTACT_LIST_FIELDS);
initializeMap(eventListFields,
SupportedPIMFields.EVENT_LIST_FIELDS);
initializeMap(todoListFields,
SupportedPIMFields.TODO_LIST_FIELDS);
try {
database = new PIMDatabase(
Configuration.getProperty("PIMRootDir") + "pim");
initialized = true;
} catch (IOException e) {
if (Logging.TRACE_ENABLED) {
Logging.trace(e, "Unable to create PIMDatabase");
}
}
}
|
private void | initializeMap(java.util.Hashtable map, PIMFieldDescriptor[] descriptors)Initialization one structure.
for (int i = 0; i < descriptors.length; i++) {
map.put(new Integer(descriptors[i].getField()), descriptors[i]);
}
|
public boolean | isSupportedArrayElement(java.lang.Object listHandle, int field, int arrayElement)Checks if the array element is supported.
return arrayElement >= 0 &&
arrayElement < getStringArraySize(listHandle, field);
|
public boolean | isSupportedAttribute(java.lang.Object listHandle, int field, int attribute)Checks if attribute is supported.
initialize();
if (attribute == PIMItem.ATTR_NONE) {
return true;
} else {
long attributes = getFieldDescriptor(((List)listHandle).type, field)
.getSupportedAttributes();
return (attributes & attribute) != 0;
}
|
public boolean | isSupportedField(java.lang.Object listHandle, int field)Checks if field is supported in list.
initialize();
return getFieldDescriptor(((List)listHandle).type, field) != null;
|
public java.lang.Object | openList(int listType, java.lang.String listName, int openMode)Opens list.
return new List(listType, listName);
|
public void | renameCategory(java.lang.Object listHandle, java.lang.String currentCategory, java.lang.String newCategory)Rename a category.
deleteCategory(listHandle, currentCategory);
addCategory(listHandle, newCategory);
|