org.geworkbench.bison.annotation
Interface DSAnnotationContextManager

All Known Implementing Classes:
CSAnnotationContextManager

public interface DSAnnotationContextManager

This defines the contract for a manager of contexts for the annotation, labelling and classification of the items of a DSItemList.

For each item list, there can be one or more DSAnnotationContexts. Additionally, there is a default context associated with each data set.

Version:
$Id: DSAnnotationContextManager.java 8357 2011-10-03 21:38:59Z zji $
Author:
John Watkinson

Method Summary
<T extends DSNamed>
DSAnnotationContext<T>
createContext(DSItemList<T> itemList, java.lang.String name)
          Creates a new context, replacing an existing context if one exists for the same item list and name.
<T extends DSNamed>
DSAnnotationContext<T>[]
getAllContexts(DSItemList<T> itemList)
          Retrieves an array of all contexts for the given item list.
<T extends DSNamed>
DSAnnotationContext<T>
getContext(DSItemList<T> itemList, int index)
          Retrieves a context by index.
<T extends DSNamed>
DSAnnotationContext<T>
getContext(DSItemList<T> itemList, java.lang.String name)
          Gets a context by name for the given item list.
<T extends DSNamed>
DSAnnotationContext<T>
getCurrentContext(DSItemList<T> itemList)
          Retrieves the currently-selected context for the given item list.
<T extends DSNamed>
int
getNumberOfContexts(DSItemList<T> itemList)
          Gets the count of contexts for the given item list.
<T extends DSNamed>
boolean
hasContext(DSItemList<T> itemList, java.lang.String name)
          Checks for the existence of a named context for an item list.
<T extends DSNamed>
boolean
removeContext(DSItemList<T> itemList, java.lang.String name)
          Removes a context by item list and name.
<T extends DSNamed>
boolean
renameContext(DSItemList<T> itemList, java.lang.String oldName, java.lang.String newName)
          Renames the specified context.
<T extends DSNamed>
void
setCurrentContext(DSItemList<T> itemList, DSAnnotationContext<T> context)
          Sets the currently-selected context.
 

Method Detail

getAllContexts

<T extends DSNamed> DSAnnotationContext<T>[] getAllContexts(DSItemList<T> itemList)
Retrieves an array of all contexts for the given item list.

Parameters:
itemList - the item list for which to retrieve contexts.
Returns:
an array of contexts.

getContext

<T extends DSNamed> DSAnnotationContext<T> getContext(DSItemList<T> itemList,
                                                      java.lang.String name)
Gets a context by name for the given item list.

Parameters:
itemList - the item list.
name - the name of the context.
Returns:
the context with the given name for the given item list, or null if it does not exist.

hasContext

<T extends DSNamed> boolean hasContext(DSItemList<T> itemList,
                                       java.lang.String name)
Checks for the existence of a named context for an item list.

Parameters:
itemList - the item list to search.
name - the name to search.
Returns:
true if the specified context exists, false otherwise.

createContext

<T extends DSNamed> DSAnnotationContext<T> createContext(DSItemList<T> itemList,
                                                         java.lang.String name)
Creates a new context, replacing an existing context if one exists for the same item list and name.

Parameters:
itemList - the item list against which the new context should be created.
name - the name of the context to create.
Returns:
the newly-created context.

getNumberOfContexts

<T extends DSNamed> int getNumberOfContexts(DSItemList<T> itemList)
Gets the count of contexts for the given item list.

Parameters:
itemList - the item list for which to count contexts.
Returns:
the number of contexts for the item list.

getContext

<T extends DSNamed> DSAnnotationContext<T> getContext(DSItemList<T> itemList,
                                                      int index)
Retrieves a context by index.

Parameters:
itemList - the item list for which to retrieve the context.
index - the index in to the list of contexts.
Returns:
the context at the specified index for the specified item list.

removeContext

<T extends DSNamed> boolean removeContext(DSItemList<T> itemList,
                                          java.lang.String name)
Removes a context by item list and name.

Parameters:
itemList - the item list for which to remove a context.
name - the name of the context to remove.
Returns:
true if the context existed before the removal, false otherwise.

renameContext

<T extends DSNamed> boolean renameContext(DSItemList<T> itemList,
                                          java.lang.String oldName,
                                          java.lang.String newName)
Renames the specified context.

Parameters:
itemList - the item list for which to rename a context.
oldName - the old name of the context.
newName - the new name of the context.
Returns:
true if a context existed by the old name, false if no such context existed.
Throws:
java.lang.IllegalArgumentException - if a context already exists for the specified item list and new name.

getCurrentContext

<T extends DSNamed> DSAnnotationContext<T> getCurrentContext(DSItemList<T> itemList)
Retrieves the currently-selected context for the given item list.

Parameters:
itemList - the item list for which to select the current context.
Returns:
the currently-selected context. If no context is explicitly selected, a default context is returned. This method never returns null.

setCurrentContext

<T extends DSNamed> void setCurrentContext(DSItemList<T> itemList,
                                           DSAnnotationContext<T> context)
Sets the currently-selected context.

Parameters:
itemList - the item list for which to set the current context.
context - the context to select.