org.ocap.hn.content.navigation
Interface ContentList

All Superinterfaces:
Enumeration
All Known Implementing Classes:
ContentDatabase

public interface ContentList
extends Enumeration

This interface represents a list of filtered ContentEntry objects.


Method Summary
 void addContentListListener(ContentListListener listener)
          Adds a ContentListListener to this ContentList.
 ContentList filterContentList(ContentDatabaseFilter filter)
          Filters the ContentList.
 ContentEntry find(String[] keys, Object[] values)
          Finds the first ContentEntry which matches the search.
 ContentEntry find(String key, Object value)
          Finds the first ContentEntry which identifier for the key 'key' equals the given object obj.
 ContentList findAll(String[] keys, Object[] values)
          Finds all ContentEntry objects which match the search.
 String[] getSortOrder()
          Gets the sort order set by the #setSortOrder method.
 void removeContentListListener(ContentListListener listener)
          Removes the specified ContentListListener.
 void setSortOrder(String[] keys)
          Sets the metadata sort order of the items in this list based on metadata key identifiers using signed property values.
 int size()
          Gets the number of ContentEntry objects in this ContentList.
 
Methods inherited from interface java.util.Enumeration
hasMoreElements, nextElement
 

Method Detail

size

int size()
Gets the number of ContentEntry objects in this ContentList.

Returns:
Number of entries in this list. Returns 0 if the list is empty.

setSortOrder

void setSortOrder(String[] keys)
Sets the metadata sort order of the items in this list based on metadata key identifiers using signed property values. For example, an entry could have the metadata key identifiers: "Title", "Artist", "CD", year (expressed as an Integer). To sort the entries in the order Artist, CD,title the following array is passed in: String[] sort = {"+Artist","-CD","+Title"}; Where the plus sign causes an ascending sort and the minus sign causes a descending sort.

Parameters:
keys - Array of metadata keys containing the sort order.

getSortOrder

String[] getSortOrder()
Gets the sort order set by the #setSortOrder method.

Returns:
The array of sort keys, or null if the setPreferredSortOrder method has not been called for this list.

find

ContentEntry find(String key,
                  Object value)
Finds the first ContentEntry which identifier for the key 'key' equals the given object obj. For instance, if key == "Title" then obj represents the title, e.g. "Best movie ever" and this method will return the first ContentEntry in the list than contains a match for the (key, value) pair.

Parameters:
key - The identifier key.
value - The object to compare to
Returns:
The first matched ContentEntry, or null if no match found.

find

ContentEntry find(String[] keys,
                  Object[] values)
Finds the first ContentEntry which matches the search. The keys and values parameters are parallel arrays. For example, if keys[0] == "TITLE" and values[0] == "Best movie ever", the implementation SHALL match the first ContentEntry in the list where the metadata contains that (key, value) pair, as well as matches any other entries in the parameter arrays.

Parameters:
keys - Array of identifier keys.
values - Array of values.
Returns:
The first matching ContentEntry found, or null if no match. If the parameter arrays are not the same length this method returns null.

findAll

ContentList findAll(String[] keys,
                    Object[] values)
Finds all ContentEntry objects which match the search. Same as the #find(String[], Object[]) method except all matches are returned instead of just the first match.

Parameters:
keys - Array of identifier keys.
values - Array of values.
Returns:
A ContentList containing all matches, or null if no matches were found.

addContentListListener

void addContentListListener(ContentListListener listener)
Adds a ContentListListener to this ContentList.

Parameters:
listener - the Listener that will receive ContentListEvents.

removeContentListListener

void removeContentListListener(ContentListListener listener)
Removes the specified ContentListListener.

Parameters:
listener - the Listener to remove

filterContentList

ContentList filterContentList(ContentDatabaseFilter filter)
                              throws DatabaseException
Filters the ContentList. The returned ContentList is a new ContentList only containing ContentItems on which ContentDatabaseFilter.accept returned true.

Parameters:
filter - the ContentDatabaseFilter
Returns:
newly created ContentList containing only the filtered ContentItems.
Throws:
DatabaseException; - see DatabaseException for exception reasons.
DatabaseException