org.beanfabrics.model
Interface Selection<T extends PresentationModel>

Type Parameters:
T - the element type of this selection.
All Superinterfaces:
java.util.Collection<T>, java.lang.Iterable<T>

public interface Selection<T extends PresentationModel>
extends java.util.Collection<T>

The Selection maintains a subset of the elements of a IListPM that are selected.

Please note: an index parameter always refers to the element's position inside the reference collection and not to the position inside the selection.

See Also:
IListPM

Method Summary
 void addAll()
          Change the selection to be equal the complete reference collection.
 boolean addInterval(int beginIndex, int endIndex)
          Change the selection to be the set union of the current selection and the elements with indices between beginIndex and endIndex inclusive.
 boolean contains(int index)
          Returns true if this the element at the specified index in the related collection is selected.
 T getFirst()
          Returns the first selected element in the reference collection.
 int[] getIndexes()
          Returns the indexes of all selected elements in the reference collection.
 int[] getIndexes(int beginIndex, int endIndex)
          Returns the indexes of the selected elements with indices between beginIndex and endIndex inclusive.
 int getMaxIndex()
          Returns the element index of the last selected element in the reference collection.
 int getMinIndex()
          Returns the element index of the first selected element in the reference collection.
 boolean removeInterval(int beginIndex, int endIndex)
          Change the selection to be the set difference of the current selection and the elements with indices between beginIndex and endIndex inclusive.
 boolean setIndexes(int[] selIndices)
          Change the selection to be the elements with the given indices.
 boolean setInterval(int beginIndex, int endIndex)
          Change the selection to be the elements with indices between beginIndex and endIndex inclusive.
 java.util.Collection<T> toCollection()
          Returns a new Collection with all selected elements.
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

contains

boolean contains(int index)
Returns true if this the element at the specified index in the related collection is selected.

Parameters:
index - the index to check
Returns:
true if this the element at the specified index in the related collection is selected

addInterval

boolean addInterval(int beginIndex,
                    int endIndex)
Change the selection to be the set union of the current selection and the elements with indices between beginIndex and endIndex inclusive. beginIndex must be less or equal endIndex.

Parameters:
beginIndex - the index of the first element to select
endIndex - the index of the last element to select (included in the selection)
Returns:
true if this selection has been changed

setInterval

boolean setInterval(int beginIndex,
                    int endIndex)
Change the selection to be the elements with indices between beginIndex and endIndex inclusive. beginIndex must be less or equal endIndex.

Parameters:
beginIndex - the index of the first element to select
endIndex - the index of the last element to select (included in the selection)
Returns:
true if this selection has been changed

removeInterval

boolean removeInterval(int beginIndex,
                       int endIndex)
Change the selection to be the set difference of the current selection and the elements with indices between beginIndex and endIndex inclusive. beginIndex must be less or equal endIndex.

Parameters:
beginIndex - the index of the first element to unselect
endIndex - the index of the last element to unselect (excluded from the selection)
Returns:
true if this selection has been changed

getMinIndex

int getMinIndex()
Returns the element index of the first selected element in the reference collection. The first selected element is the selected element with the smallest index.

Returns:
the element index of the first selected element or -1 if none is selected

getMaxIndex

int getMaxIndex()
Returns the element index of the last selected element in the reference collection. The last selected element is the selected element with the greatest index.

Returns:
the element index of the last selected element or -1 if none is selected

addAll

void addAll()
Change the selection to be equal the complete reference collection.


getFirst

T getFirst()
Returns the first selected element in the reference collection. The first selected element is the selected element with the smallest index.

Returns:
the first selected element
See Also:
getMinIndex()

getIndexes

int[] getIndexes()
Returns the indexes of all selected elements in the reference collection.

Returns:
the indexes of all selected elements

getIndexes

int[] getIndexes(int beginIndex,
                 int endIndex)
Returns the indexes of the selected elements with indices between beginIndex and endIndex inclusive.

Parameters:
beginIndex -
endIndex -
Returns:
the indexes of the selected elements within the specified bounds

setIndexes

boolean setIndexes(int[] selIndices)
Change the selection to be the elements with the given indices.

Parameters:
selIndices - the indices of the elements to select
Returns:
true if this selection has been changed

toCollection

java.util.Collection<T> toCollection()
Returns a new Collection with all selected elements. Modification on this collection will not influence the original selection.

Returns:
a new Collection with all selected elements