public class RecordList extends BaseClass implements HasDataChangedHandlers
This class is expected by list-oriented display components such as the ListGrid.
Modifier and Type | Class and Description |
---|---|
static interface |
RecordList.SortNormalizer |
Modifier and Type | Field and Description |
---|---|
protected com.google.gwt.core.client.JavaScriptObject |
jsObj |
config, id, scClassName
Constructor and Description |
---|
RecordList()
Construct a RecordList with no initial data.
|
RecordList(com.google.gwt.core.client.JavaScriptObject jsObj) |
RecordList(java.util.List<? extends Record> data) |
RecordList(Record[] data)
Construct a RecordList with initial data.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Record record)
Add an object to this list, at the end
|
Record |
addAt(Record record,
int pos)
Add a single item to this array at a specific position in the list, sliding other items over to fit.
|
com.google.gwt.event.shared.HandlerRegistration |
addDataChangedHandler(DataChangedHandler handler)
Add a DataChanged handler.
|
void |
addList(Record[] list)
Add a list of items to this array.
|
void |
addList(Record[] list,
int listStartRow,
int listEndRow)
Add a list of items to this array.
|
void |
addListAt(Record[] list,
int pos)
Add list of items list to this array at item pos.
|
java.lang.Boolean |
contains(Record record)
Return if this list contains the specified object.
|
java.lang.Boolean |
contains(Record record,
int pos)
Return if this list contains the specified object.
|
java.lang.Boolean |
containsAll(RecordList list)
Return whether this list contains all the item in the specified list.
|
protected com.google.gwt.core.client.JavaScriptObject |
create() |
Record[] |
duplicate()
Return an Array that is a shallow copy of the list, that is, containing the same items.
|
java.lang.Boolean |
equals(RecordList list)
Return whether this list is equal to another list.
|
Record |
find(AdvancedCriteria adCriteria)
Filters all objects according to the AdvancedCriteria passed and returns the first matching object or null if not found
|
Record |
find(java.lang.String propertyName,
java.lang.Boolean value)
Like
findIndex(java.util.Map) , but returns the object itself instead of its index. |
Record |
find(java.lang.String propertyName,
java.util.Date value)
Like
findIndex(java.util.Map) , but returns the object itself instead of its index. |
Record |
find(java.lang.String propertyName,
java.lang.Long value)
Like
findIndex(java.util.Map) , but returns the object itself instead of its index. |
Record |
find(java.lang.String propertyName,
java.lang.Object value)
Like
findIndex(java.util.Map) , but returns the object itself instead of its index. |
Record[] |
findAll(AdvancedCriteria adCriteria)
Filters all objects according to the AdvancedCriteria passed
|
Record[] |
findAll(java.util.Map properties)
Find all objects where property == value in the object
|
Record[] |
findAll(java.lang.String propertyName,
boolean value)
Find all objects where property == value in the object.
|
Record[] |
findAll(java.lang.String propertyName,
java.util.Date value)
Find all objects where property == value in the object.
|
Record[] |
findAll(java.lang.String propertyName,
float value)
Find all objects where property == value in the object
|
Record[] |
findAll(java.lang.String propertyName,
int value)
Find all objects where property == value in the object
|
Record[] |
findAll(java.lang.String propertyName,
java.lang.Long value)
Find all objects where property == value in the object
|
Record[] |
findAll(java.lang.String propertyName,
java.lang.String value)
Find all objects where property == value in the object.
|
int |
findIndex(AdvancedCriteria adCriteria)
Finds the index of the first Record that matches with the AdvacendCriteria passed.
|
int |
findIndex(java.util.Map properties)
Find the index of the first Record where property == value in the object.
|
int |
findIndex(java.lang.String propertyName,
boolean value)
Find the index of the first Record where property == value in the object.
|
int |
findIndex(java.lang.String propertyName,
java.util.Date value)
Find the index of the first Record where property == value in the object.
|
int |
findIndex(java.lang.String propertyName,
float value)
Find the index of the first Record where property == value in the object.
|
int |
findIndex(java.lang.String propertyName,
int value)
Find the index of the first Record where property == value in the object.
|
int |
findIndex(java.lang.String propertyName,
java.lang.Long value)
Find the index of the first Record where property == value in the object.
|
int |
findIndex(java.lang.String propertyName,
java.lang.String value)
Find the index of the first Record where property == value in the object.
|
int |
findNextIndex(int startIndex,
AdvancedCriteria adCriteria)
Like
findIndex(java.util.Map) , but considering the startIndex parameter. |
int |
findNextIndex(int startIndex,
AdvancedCriteria adCriteria,
int endIndex)
Like
findIndex(java.util.Map) , but considering the startIndex and endIndex parameters. |
int |
findNextIndex(int startIndex,
java.util.Map properties)
Like
findIndex(java.util.Map) , but inspects a range from startIndex to endIndex. |
int |
findNextIndex(int startIndex,
java.lang.String propertyName)
Like
findIndex(java.util.Map) , but inspects a range from startIndex to endIndex. |
int |
findNextIndex(int startIndex,
java.lang.String propertyName,
boolean value,
int endIndex)
Like
findIndex(java.util.Map) , but inspects a range from startIndex to endIndex. |
int |
findNextIndex(int startIndex,
java.lang.String propertyName,
java.util.Date value,
int endIndex)
Like
findIndex(java.util.Map) , but inspects a range from startIndex to endIndex. |
int |
findNextIndex(int startIndex,
java.lang.String propertyName,
float value,
int endIndex)
Like
findIndex(java.util.Map) , but inspects a range from startIndex to endIndex. |
int |
findNextIndex(int startIndex,
java.lang.String propertyName,
int value,
int endIndex)
Like
findIndex(java.util.Map) , but inspects a range from startIndex to endIndex. |
int |
findNextIndex(int startIndex,
java.lang.String propertyName,
java.lang.Long value,
int endIndex)
Like
findIndex(java.util.Map) , but inspects a range from startIndex to endIndex. |
int |
findNextIndex(int startIndex,
java.lang.String propertyName,
java.lang.String value,
int endIndex)
Like
findIndex(java.util.Map) , but inspects a range from startIndex to endIndex. |
Record |
first()
Return the first item in this list
|
Record |
get(int pos)
Return the item at a particular position
|
Record[] |
getItems(int[] itemList)
Return the items at a list of specified positions.
|
com.google.gwt.core.client.JavaScriptObject |
getJsObj() |
int |
getLength()
Return the number of items in this list
|
com.google.gwt.core.client.JavaScriptObject |
getOrCreateJsObj() |
static RecordList |
getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj) |
Record[] |
getProperty(java.lang.String property)
Return a new Array where the value of item i is the value of "property" of item i in this array.
|
Record[] |
getRange(int start,
int end)
Return the items between position start and end, non-inclusive at the end.
|
RecordList |
getRangeList(int start,
int end)
Return a RecordList with the items between position start and end, non-inclusive at the end.
|
java.util.Map |
getValueMap(java.lang.String idField,
java.lang.String displayField)
Get a map of the form
{ item[idField] -> item[displayField] } , for all items in the list. |
int |
indexOf(Record record)
Return the position in the list of the first instance of the specified object.
|
int |
indexOf(Record record,
int pos,
int endPos)
Return the position in the list of the first instance of the specified object.
|
RecordList |
intersect(RecordList list)
Return the list of items that are in both this list and the passed-in list.
|
static boolean |
isARecordList(java.lang.Object obj) |
boolean |
isCreated() |
java.lang.Boolean |
isEmpty()
Return whether or not this array is empty
|
Record |
last()
Return the last item in this list
|
int |
lastIndexOf(Record record)
Return the position in the list of the last instance of the specified object.
|
int |
lastIndexOf(Record record,
int pos,
int endPos)
Return the position in the list of the last instance of the specified object.
|
java.lang.Boolean |
remove(Record record)
Remove first instance of the passed object from this array, sliding other items around to fill gaps.
|
Record |
removeAt(int pos)
Remove the item at the specified position, rearranging all subsequent items to fill the gap
|
void |
removeList(Record[] list)
Remove all instances of objects in the specified list from this list, sliding the remaining objects around to fill gaps.
|
Record |
set(int pos,
Record record)
Change the array element at a particular position.
|
void |
setLength(int length)
Set the length of this list.
|
void |
setSort(SortSpecifier... sortSpecifiers)
Multi-Property sort.
|
void |
sort()
Sorts the elements of the List in place.
|
RecordList |
sort(java.util.Comparator<Record> comparator)
Sorts the elements of the List in place.
|
RecordList |
sortByProperty(java.lang.String property,
boolean up)
Sort a list of objects by a given property of each item.
|
void |
sortByProperty(java.lang.String property,
boolean up,
RecordList.SortNormalizer normalizer)
Sort this ResultSet by a property of each record.
|
Record[] |
toArray()
Returns the records in this RecordList as an array.
|
asSGWTComponent, createJsObj, destroy, doAddHandler, doInit, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getClassName, getConfig, getHandlerCount, getID, getRef, getScClassName, hasAutoAssignedID, internalSetID, internalSetID, onBind, onInit, registerID, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setConfig, setID, setJavaScriptObject, setProperty, setProperty, setProperty, setProperty, setScClassName
public RecordList()
public RecordList(Record[] data)
data
- initial Record datapublic RecordList(java.util.List<? extends Record> data)
public RecordList(com.google.gwt.core.client.JavaScriptObject jsObj)
public static boolean isARecordList(java.lang.Object obj)
public static RecordList getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
protected com.google.gwt.core.client.JavaScriptObject create()
public com.google.gwt.core.client.JavaScriptObject getJsObj()
public com.google.gwt.core.client.JavaScriptObject getOrCreateJsObj()
getOrCreateJsObj
in class BaseClass
public Record get(int pos)
pos
- position of the element to getpublic int getLength()
public java.lang.Boolean isEmpty()
public Record first()
public Record last()
public int indexOf(Record record)
If pos is specified, starts looking after that position.
Returns -1 if not found.
record
- object to look forpublic int indexOf(Record record, int pos, int endPos)
If pos is specified, starts looking after that position.
Returns -1 if not found.
record
- object to look forpos
- earliest index to considerendPos
- last index to considerpublic int lastIndexOf(Record record)
If pos is specified, starts looking before that position.
Returns -1 if not found.
record
- object to look forpublic int lastIndexOf(Record record, int pos, int endPos)
If pos is specified, starts looking before that position.
Returns -1 if not found.
record
- object to look forpos
- last index to considerendPos
- earliest index to considerpublic int findIndex(java.util.Map properties)
Note: for string values, matches are case sensitive.
properties
- set of properties and values to matchpublic int findIndex(java.lang.String propertyName, java.lang.String value)
Note: for string values, matches are case sensitive.
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)public int findIndex(java.lang.String propertyName, int value)
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)public int findIndex(java.lang.String propertyName, java.lang.Long value)
Note: JavaScript has no long type, so the long value becomes a JavaScript Number, which has a lesser range than Java long. The range for integer numbers in Javascript is [-9007199254740992,9007199254740992] or [-Math.pow(2,53),Math.pow(2,53)].
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)public int findIndex(java.lang.String propertyName, float value)
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)public int findIndex(java.lang.String propertyName, boolean value)
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)public int findIndex(java.lang.String propertyName, java.util.Date value)
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)public int findNextIndex(int startIndex, java.lang.String propertyName)
findIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.startIndex
- first index to considerpropertyName
- property to matchpublic int findNextIndex(int startIndex, java.util.Map properties)
findIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.startIndex
- first index to considerproperties
- set of properties and values to matchpublic int findNextIndex(int startIndex, java.lang.String propertyName, java.lang.String value, int endIndex)
findIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.startIndex
- first index to considerpropertyName
- property to matchvalue
- value to compare against (if propertyName is a string)endIndex
- last index to considerpublic int findNextIndex(int startIndex, java.lang.String propertyName, int value, int endIndex)
findIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.startIndex
- first index to considerpropertyName
- property to matchvalue
- value to compare against (if propertyName is a string)endIndex
- last index to considerpublic int findNextIndex(int startIndex, java.lang.String propertyName, java.lang.Long value, int endIndex)
findIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.
Note: JavaScript has no long type, so the long value becomes a JavaScript Number, which has a lesser range than Java long. The range for integer numbers in Javascript is [-9007199254740992,9007199254740992] or [-Math.pow(2,53),Math.pow(2,53)].
startIndex
- first index to considerpropertyName
- property to matchvalue
- value to compare against (if propertyName is a string)endIndex
- last index to considerpublic int findNextIndex(int startIndex, java.lang.String propertyName, float value, int endIndex)
findIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.startIndex
- first index to considerpropertyName
- property to matchvalue
- value to compare against (if propertyName is a string)endIndex
- last index to considerpublic int findNextIndex(int startIndex, java.lang.String propertyName, boolean value, int endIndex)
findIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.startIndex
- first index to considerpropertyName
- property to matchvalue
- value to compare against (if propertyName is a string)endIndex
- last index to considerpublic int findNextIndex(int startIndex, java.lang.String propertyName, java.util.Date value, int endIndex)
findIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.startIndex
- first index to considerpropertyName
- property to matchvalue
- value to compare against (if propertyName is a string)endIndex
- last index to considerpublic Record find(java.lang.String propertyName, java.lang.Object value)
findIndex(java.util.Map)
, but returns the object itself instead of its index.propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)public Record find(java.lang.String propertyName, java.util.Date value)
findIndex(java.util.Map)
, but returns the object itself instead of its index.propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)public Record find(java.lang.String propertyName, java.lang.Long value)
findIndex(java.util.Map)
, but returns the object itself instead of its index.
Note: JavaScript has no long type, so the long value becomes a JavaScript Number, which has a lesser range than Java long. The range for integer numbers in Javascript is [-9007199254740992,9007199254740992] or [-Math.pow(2,53),Math.pow(2,53)].
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)public Record find(java.lang.String propertyName, java.lang.Boolean value)
findIndex(java.util.Map)
, but returns the object itself instead of its index.propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)public Record[] findAll(java.util.Map properties)
properties
- set of properties and values to
matchpublic Record[] findAll(java.lang.String propertyName, java.lang.String value)
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)public Record[] findAll(java.lang.String propertyName, int value)
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)public Record[] findAll(java.lang.String propertyName, java.lang.Long value)
Note: JavaScript has no long type, so the long value becomes a JavaScript Number, which has a lesser range than Java long. The range for integer numbers in Javascript is [-9007199254740992,9007199254740992] or [-Math.pow(2,53),Math.pow(2,53)].
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)public Record[] findAll(java.lang.String propertyName, float value)
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)public Record[] findAll(java.lang.String propertyName, boolean value)
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)public Record[] findAll(java.lang.String propertyName, java.util.Date value)
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)public Record[] findAll(AdvancedCriteria adCriteria)
adCriteria
- AdvancedCriteria to use to filter resultspublic Record find(AdvancedCriteria adCriteria)
adCriteria
- AdvancedCriteria to use to filter resultspublic int findIndex(AdvancedCriteria adCriteria)
adCriteria
- AdvancedCriteria to use to filter resultspublic int findNextIndex(int startIndex, AdvancedCriteria adCriteria, int endIndex)
findIndex(java.util.Map)
, but considering the startIndex and endIndex parameters.startIndex
- first index to consideradCriteria
- AdvancedCriteria to use to filter resultsendIndex
- last index to considerpublic int findNextIndex(int startIndex, AdvancedCriteria adCriteria)
findIndex(java.util.Map)
, but considering the startIndex parameter.startIndex
- first index to consideradCriteria
- AdvancedCriteria to use to filter resultspublic java.lang.Boolean contains(Record record)
record
- item to look forpublic java.lang.Boolean contains(Record record, int pos)
If pos is specified, starts looking after that position.
record
- item to look forpos
- optional position in the list to look afterpublic java.lang.Boolean containsAll(RecordList list)
list
- items to look forpublic RecordList intersect(RecordList list)
list
- list to intersect withpublic java.lang.Boolean equals(RecordList list)
Two lists are equal only if they have the same length and all contained items are in the same order and are also equal.
list
- list to check for equalitypublic Record[] getItems(int[] itemList)
itemList
- array of positionspublic Record[] getRange(int start, int end)
start
- start positionend
- end positionpublic Record[] duplicate()
public Record set(int pos, Record record)
set() can be used to expand the length of the list.
pos
- position in the list to changerecord
- new value for that positionpublic Record addAt(Record record, int pos)
record
- object to addpos
- position in the list to add atpublic Record removeAt(int pos)
pos
- position to removepublic void add(Record record)
record
- object to addpublic void addList(Record[] list)
Note: you can specify that a subset range be added by passing start and end indices
list
- list of items to addpublic void addList(Record[] list, int listStartRow, int listEndRow)
Note: you can specify that a subset range be added by passing start and end indices
list
- list of items to addlistStartRow
- optional start index in listlistEndRow
- optional end index in list (non-inclusive)public void setLength(int length)
If the length of the list is shortened, any elements past the new length of the list
are removed. If the length is increased, all positions past the old length have the value undefined
.
length
- new lengthpublic void addListAt(Record[] list, int pos)
list
- new array of itemspos
- position in this list to put the new itemspublic java.lang.Boolean remove(Record record)
record
- item to removepublic void removeList(Record[] list)
list
- list of items to removepublic void sort()
The optional comparator function should take two parameters "a" and "b" which are the two list items to compare, and should return:
public RecordList sort(java.util.Comparator<Record> comparator)
The optional comparator function should take two parameters "a" and "b" which are the two list items to compare, and should return:
comparator
- comparator function to usepublic Record[] getProperty(java.lang.String property)
property
- name of the property to look forpublic RecordList sortByProperty(java.lang.String property, boolean up)
The optional normalizer, if passed as a function, is called for each item in the List, and should return whatever value should be used for sorting, which does not have to agree with the property value. By passing a normalizer function you can achieve any kind of sorting you'd like, including sorting by multiple properties.
NOTE: string sort is case INsensitive by default
property
- name of the property to sort byup
- true == sort ascending, false == sort descendingpublic void sortByProperty(java.lang.String property, boolean up, RecordList.SortNormalizer normalizer)
Sorting is performed on the client for a ResultSet that has a full cache for the current filter criteria. Otherwise, sorting is performed by the server, and changing the sort order will invalidate the cache.
NOTE: normalizers are not supported by ResultSets in "paged" mode
property
- name of the property to sort byup
- true == sort ascending, false == sort descendingnormalizer
- May be specified as a callbac with signature normalize(item, propertyName)
, where
item
is reference to the item in the array, propertyName
is the
property by which the array is being sorted. Normalizer function should return the value normalized for sorting.public void setSort(SortSpecifier... sortSpecifiers)
SortSpecifier
's.sortSpecifiers
- a list of SortSpecifier
objects, one per sort-field and directionpublic java.util.Map getValueMap(java.lang.String idField, java.lang.String displayField)
{ item[idField] -> item[displayField] }
, for all items in the list. Note that if
more than one item has the same idProperty
, the value for the later item in the list will clobber the
value for the earlier item.idField
- Property to use as ID (data value) in the valueMapdisplayField
- Property to use a display value in the valueMappublic com.google.gwt.event.shared.HandlerRegistration addDataChangedHandler(DataChangedHandler handler)
Notification fired when data changes in some way. Note that this will only fire when items are added, removed or rearranged. If a list contains objects, this method will not fire if changes are made to objects within the list without changing their position within the list
addDataChangedHandler
in interface HasDataChangedHandlers
handler
- the DataChanged handlerHandlerRegistration
used to remove this handlerpublic Record[] toArray()
public RecordList getRangeList(int start, int end)
start
- start positionend
- end position