|
com.im.df.api 5.8 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.im.df.api.support.SelectionDescription
public final class SelectionDescription
Generic description of selection. Each selection can be in one of the following (disjunct) states:
isEmpty() => trueisSingleRow() => falseisSingleInterval() => falseisMultiInterval() => falseEMPTY.
You can compare it using == operator.
isEmpty() => falseisSingleRow() => trueisSingleInterval() => falseisMultiInterval() => false.isEmpty() => falseisSingleRow() => falseisSingleInterval() => trueisMultiInterval() => false.isEmpty() => falseisSingleRow() => falseisSingleInterval() => falseisMultiInterval() => true.SelectionDescription is an immutable object - once it is created it cannot be changed. You need to create a new one if you want to change the selection.
SelectionDescription implements Iterable interface which iterates through selected indices of the instance.
Note that this allows SelectionDescription instance to be used in foreach loop:
SelectionDescription selection = ...;
for (Integer selectedIndex : selection) {
// do something with selectedIndex
}
Selection have a subselection which is represented as another SelectionDescription instance and can be obatined with
getSubSelection() method. Subselection contains a subset of indexes of its main selection. E.g.:
Selection: {100, 101, ..., 110}
Subselection: {102, 105, 106}
To get a relative subselection, i.e. indexes into main selection, use getRelativeSubSelection() method. There
are several other methods to work with subselection. See Javadoc of individual methods for details.
| Field Summary | |
|---|---|
static SelectionDescription |
EMPTY
Empty selection |
| Method Summary | |
|---|---|
static SelectionDescription |
complement(SelectionDescription sd1,
SelectionDescription sd2)
Returns selection description containing relative complement of sd2 in sd1. |
static SelectionDescription |
convertToAbsoluteSubSelection(SelectionDescription selection,
Collection<? extends Integer> relativeSubselection)
Takes relative subselection in form of a Collection and converts it to absolute subselection
within the given selection. |
static SelectionDescription |
convertToAbsoluteSubSelection(SelectionDescription selection,
ListSelectionModel relativeSubselection)
Takes relative subselection in form of a ListSelectionModel and converts it to absolute
subselection within the given selection. |
static SelectionDescription |
create(int singleRowIndex)
Creates the single row selection |
static SelectionDescription |
create(int minIndex,
int maxIndex)
Create selection for a single interval [min,max]. |
static SelectionDescription |
create(List<? extends Integer> indexes)
Crete a new selection based on the given indexes. |
static SelectionDescription |
create(ListSelectionModel listSelectionModel)
Returns a new selection from a ListSelectionModel with empty subselection. |
static SelectionDescription |
create(ListSelectionModel listSelectionModel,
SelectionDescription subSelection)
Returns a new selection having main selection corresponding to a given ListSelectionModel with
subselection set to given subSelection parameter. |
static SelectionDescription |
create(SelectionDescription oldSel,
List<? extends Comparable<?>> oldIds,
List<? extends Comparable<?>> newIds)
This method can be used when ids are reordered or completely changed and you want to recalculate the selection. |
static SelectionDescription |
create(SelectionDescription selection,
ListSelectionModel listSubSelectionModel)
Returns a new selection having main selection same as a given selection and subselection corresponding to
a given ListSelectionModel. |
static SelectionDescription |
create(SelectionDescription selection,
SelectionDescription subSelection)
Create selection for a single interval [min,max]. |
boolean |
equals(Object obj)
|
int |
getMaxSelectionIndex()
Returns the last selected index or -1 if the selection is empty. |
int |
getMinSelectionIndex()
Returns the first selected index or -1 if the selection is empty. |
SelectionDescription |
getRelativeSubSelection()
Returns subselection of this selection but with indexes relative to this selection. |
int |
getSelectedRowsCount()
Get count of rows represented by this selection. |
SelectionDescription |
getSubSelection()
Returns subselection within this selection. |
int |
hashCode()
|
static SelectionDescription |
intersection(SelectionDescription sd1,
SelectionDescription sd2)
Returns intersection of the given selection descriptions. |
boolean |
isEmpty()
Is the selection empty? |
boolean |
isMultiInterval()
Does this selection represent more intervals? |
boolean |
isSelectedIndex(int index)
Returns true if the specified index is selected. |
boolean |
isSingleInterval()
Does this selection represent a single interval? |
boolean |
isSingleRow()
Does this selection represent a single row? |
Iterator<Integer> |
iterator()
|
static SelectionDescription |
move(SelectionDescription origSelection,
int delta,
int rowCount)
Create a new moved selection based on original one. |
String |
toString()
|
String |
toStringSimple(boolean startFromRowOne)
Return only selected rows indexes. |
static SelectionDescription |
union(SelectionDescription sd1,
SelectionDescription sd2)
Returns union of the given selection descriptions. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final SelectionDescription EMPTY
| Method Detail |
|---|
public static SelectionDescription create(SelectionDescription oldSel,
List<? extends Comparable<?>> oldIds,
List<? extends Comparable<?>> newIds)
New selection contains obviously only those values which are present in newIds list. It means new selection will contain the same or less selected rows. In extreme case new selection can be EMPTY (if no originally selected value is present in newIds).
oldSel - The original selectionoldIds - The original list of ids (usually primary key values)newIds - The new list of ids (can contain the same or completely different values)
public static SelectionDescription union(SelectionDescription sd1,
SelectionDescription sd2)
sd1 or in sd2.
public static SelectionDescription intersection(SelectionDescription sd1,
SelectionDescription sd2)
sd1 and sd2.
public static SelectionDescription complement(SelectionDescription sd1,
SelectionDescription sd2)
sd2 in sd1. I.e. indices which
are selected in sd1 but not in sd2.
public static SelectionDescription create(List<? extends Integer> indexes)
indexes - indexes to be selected.
public static SelectionDescription create(int singleRowIndex)
public static SelectionDescription create(ListSelectionModel listSelectionModel,
SelectionDescription subSelection)
ListSelectionModel with
subselection set to given subSelection parameter.
listSelectionModel - main selectionsubSelection - subselection
public static SelectionDescription create(SelectionDescription selection,
ListSelectionModel listSubSelectionModel)
selection and subselection corresponding to
a given ListSelectionModel.
selection - main selectionlistSubSelectionModel - subselection
public static SelectionDescription create(ListSelectionModel listSelectionModel)
ListSelectionModel with empty subselection.
listSelectionModel - main selection
public static SelectionDescription create(int minIndex,
int maxIndex)
public static SelectionDescription create(SelectionDescription selection,
SelectionDescription subSelection)
public static SelectionDescription move(SelectionDescription origSelection,
int delta,
int rowCount)
origSelection - Original selection to be moveddelta - The number of rows to move the selection. Can be either positive or negative number.rowCount - The total number of rows in the table. This parameter is here because of
overflow prevention. New selection will respect this table size and won't go over it.
public static SelectionDescription convertToAbsoluteSubSelection(SelectionDescription selection,
ListSelectionModel relativeSubselection)
ListSelectionModel and converts it to absolute
subselection within the given selection. I.e. if range of the given selection is <100, 110> and
given relativeSubselection contains (3, 4, 5, 8) the result is a new SelectionDescription instance with
(103, 104, 105, 108) indices.
selection - main selectionrelativeSubselection - relative subselection within the given selection
selection
public static SelectionDescription convertToAbsoluteSubSelection(SelectionDescription selection,
Collection<? extends Integer> relativeSubselection)
Collection and converts it to absolute subselection
within the given selection. I.e. if range of the given selection is <100, 110> and given relativeSubselection contains (3, 4, 5, 8) the result is a new SelectionDescription instance with (103, 104,
105, 108) indices.
selection - main selectionrelativeSubselection - relative subselection within the given selection
selectionpublic SelectionDescription getRelativeSubSelection()
public SelectionDescription getSubSelection()
nullpublic Iterator<Integer> iterator()
iterator in interface Iterable<Integer>public int getMinSelectionIndex()
public int getMaxSelectionIndex()
public int getSelectedRowsCount()
public boolean isSingleRow()
public boolean isSingleInterval()
public boolean isMultiInterval()
public boolean isEmpty()
public boolean isSelectedIndex(int index)
public boolean equals(Object obj)
equals in class Objectpublic String toStringSimple(boolean startFromRowOne)
startFromRowOne - If true first row has number 1; otherwise 0.public String toString()
toString in class Objectpublic int hashCode()
hashCode in class Object
|
com.im.df.api 5.8 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||