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.

Author:
John Watkinson

Method Summary
<T extends DSNamed>
void
copyContexts(DSItemList<T> from, DSItemList<T> to)
          Copies all context from one item list to another.
<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.
 boolean hasContext(DSItemList itemList, java.lang.String name)
          Checks for the existence of a named context for an item list.
 boolean removeContext(DSItemList itemList, java.lang.String name)
          Removes a context by item list and name.
 boolean renameContext(DSItemList 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

boolean hasContext(DSItemList 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

boolean removeContext(DSItemList 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

boolean renameContext(DSItemList 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.

copyContexts

<T extends DSNamed> void copyContexts(DSItemList<T> from,
                                      DSItemList<T> to)
Copies all context from one item list to another. The results are undefined if the target item list does not contain all the elements of the source item list. However, the order of the elements need not be the same between the two lists.

Parameters:
from - the source item list.
to - the target item list.