Class RecordList
- All Implemented Interfaces:
HasHandlers
,HasDataChangedHandlers
This class is expected by list-oriented display components such as the ListGrid.
-
Nested Class Summary
-
Field Summary
Fields inherited from class com.smartgwt.client.core.BaseClass
config, configOnly, factoryCreated, factoryProperties, id, scClassName
-
Constructor Summary
ConstructorDescriptionConstruct a RecordList with no initial data.RecordList
(JavaScriptObject jsObj) RecordList
(Record[] data) Construct a RecordList with initial data.RecordList
(List<? extends Record> data) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add an object to this list, at the endAdd a single item to this array at a specific position in the list, sliding other items over to fit.addDataChangedHandler
(DataChangedHandler handler) Add a DataChanged handler.void
Add a list of items to this array.void
Add a list of items to this array.void
Add list of items list to this array at item pos.Return if this list contains the specified object.Return if this list contains the specified object.containsAll
(RecordList list) Return whether this list contains all the item in the specified list.protected JavaScriptObject
create()
Record[]
Return an Array that is a shallow copy of the list, that is, containing the same items.equals
(RecordList list) Return whether this list is equal to another list.find
(AdvancedCriteria adCriteria) Filters all objects according to the AdvancedCriteria passed and returns the first matching object or null if not foundLikefindIndex(java.util.Map)
, but returns the object itself instead of its index.LikefindIndex(java.util.Map)
, but returns the object itself instead of its index.LikefindIndex(java.util.Map)
, but returns the object itself instead of its index.LikefindIndex(java.util.Map)
, but returns the object itself instead of its index.Record[]
findAll
(AdvancedCriteria adCriteria) Filters all objects according to the AdvancedCriteria passedRecord[]
Find all objects where property == value in the object.Record[]
Find all objects where property == value in the objectRecord[]
Find all objects where property == value in the objectRecord[]
Find all objects where property == value in the objectRecord[]
Find all objects where property == value in the object.Record[]
Find all objects where property == value in the object.Record[]
Find all objects where property == value in the objectint
findIndex
(AdvancedCriteria adCriteria) Finds the index of the first Record that matches with the AdvacendCriteria passed.int
Find the index of the first Record where property == value in the object.int
Find the index of the first Record where property == value in the object.int
Find the index of the first Record where property == value in the object.int
Find the index of the first Record where property == value in the object.int
Find the index of the first Record where property == value in the object.int
Find the index of the first Record where property == value in the object.int
Find the index of the first Record where property == value in the object.int
findNextIndex
(int startIndex, AdvancedCriteria adCriteria) LikefindIndex(java.util.Map)
, but considering the startIndex parameter.int
findNextIndex
(int startIndex, AdvancedCriteria adCriteria, int endIndex) LikefindIndex(java.util.Map)
, but considering the startIndex and endIndex parameters.int
findNextIndex
(int startIndex, String propertyName) LikefindIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.int
findNextIndex
(int startIndex, String propertyName, boolean value, int endIndex) LikefindIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.int
findNextIndex
(int startIndex, String propertyName, float value, int endIndex) LikefindIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.int
findNextIndex
(int startIndex, String propertyName, int value, int endIndex) LikefindIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.int
findNextIndex
(int startIndex, String propertyName, Long value, int endIndex) LikefindIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.int
findNextIndex
(int startIndex, String propertyName, String value, int endIndex) LikefindIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.int
findNextIndex
(int startIndex, String propertyName, Date value, int endIndex) LikefindIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.int
findNextIndex
(int startIndex, Map properties) LikefindIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.first()
Return the first item in this listget
(int pos) Return the item at a particular positionRecord[]
getItems
(int[] itemList) Return the items at a list of specified positions.getJsObj()
int
Return the number of items in this liststatic RecordList
getOrCreateRef
(JavaScriptObject jsObj) Object[]
getProperty
(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.getRangeList
(int start, int end) Return a RecordList with the items between position start and end, non-inclusive at the end.getValueMap
(String idField, String displayField) Get a map of the form{ item[idField] -> item[displayField] }
, for all items in the list.int
Return the position in the list of the first instance of the specified object.int
Return the position in the list of the first instance of the specified object.intersect
(RecordList list) Return the list of items that are in both this list and the passed-in list.static boolean
isARecordList
(Object obj) boolean
isEmpty()
Return whether or not this array is emptylast()
Return the last item in this listint
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.Remove first instance of the passed object from this array, sliding other items around to fill gaps.removeAt
(int pos) Remove the item at the specified position, rearranging all subsequent items to fill the gapvoid
removeList
(Record[] list) Remove all instances of objects in the specified list from this list, sliding the remaining objects around to fill gaps.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.sort
(Comparator<Record> comparator) Sorts the elements of the List in place.sortByProperty
(String property, boolean up) Sort a list of objects by a given property of each item.void
sortByProperty
(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.Methods inherited from class com.smartgwt.client.core.BaseClass
addDynamicProperty, addDynamicProperty, addDynamicProperty, addDynamicProperty, applyFactoryProperties, asSGWTComponent, clearDynamicProperty, createJsObj, destroy, doAddHandler, doInit, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getClassName, getConfig, getHandlerCount, getID, getRef, getRuleScope, getScClassName, getTestInstance, hasAutoAssignedID, hasDynamicProperty, internalSetID, internalSetID, isConfigOnly, isFactoryCreated, onBind, onInit, registerID, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setConfig, setConfigOnly, setFactoryCreated, setID, setJavaScriptObject, setProperty, setProperty, setProperty, setProperty, setRuleScope, setScClassName
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
-
Field Details
-
jsObj
-
-
Constructor Details
-
RecordList
public RecordList()Construct a RecordList with no initial data. Use the various add* methods to add Records to this list. -
RecordList
Construct a RecordList with initial data.- Parameters:
data
- initial Record data
-
RecordList
-
RecordList
-
-
Method Details
-
isARecordList
-
getOrCreateRef
-
create
-
getJsObj
-
isCreated
public boolean isCreated() -
getOrCreateJsObj
- Overrides:
getOrCreateJsObj
in classBaseClass
-
get
Return the item at a particular position- Parameters:
pos
- position of the element to get- Returns:
- whatever's at that position, null if not found
-
getLength
public int getLength()Return the number of items in this list- Returns:
- number of items in the list
-
isEmpty
Return whether or not this array is empty- Returns:
- true == this array is empty, false == some items in the array
-
first
Return the first item in this list- Returns:
- first item in the list
-
last
Return the last item in this list- Returns:
- last item in the list
-
indexOf
Return the position in the list of the first instance of the specified object.If pos is specified, starts looking after that position.
Returns -1 if not found.
- Parameters:
record
- object to look for- Returns:
- position of the item, if found, -1 if not found
-
indexOf
Return the position in the list of the first instance of the specified object.If pos is specified, starts looking after that position.
Returns -1 if not found.
- Parameters:
record
- object to look forpos
- earliest index to considerendPos
- last index to consider- Returns:
- position of the item, if found, -1 if not found
-
lastIndexOf
Return the position in the list of the last instance of the specified object.If pos is specified, starts looking before that position.
Returns -1 if not found.
- Parameters:
record
- object to look for- Returns:
- position of the item, if found, -1 if not found
-
lastIndexOf
Return the position in the list of the last instance of the specified object.If pos is specified, starts looking before that position.
Returns -1 if not found.
- Parameters:
record
- object to look forpos
- last index to considerendPos
- earliest index to consider- Returns:
- position of the item, if found, -1 if not found
-
findIndex
Find the index of the first Record where property == value in the object.Note: for string values, matches are case sensitive.
- Parameters:
properties
- set of properties and values to match- Returns:
- index of the first matching Record or -1 if not found
-
findIndex
Find the index of the first Record where property == value in the object.Note: for string values, matches are case sensitive.
- Parameters:
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)- Returns:
- index of the first matching Record or -1 if not found
-
findIndex
Find the index of the first Record where property == value in the object.- Parameters:
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)- Returns:
- index of the first matching Record or -1 if not found
-
findIndex
Find the index of the first Record where property == value in the object.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)].
- Parameters:
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)- Returns:
- index of the first matching Record or -1 if not found
-
findIndex
Find the index of the first Record where property == value in the object.- Parameters:
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)- Returns:
- index of the first matching Record or -1 if not found
-
findIndex
Find the index of the first Record where property == value in the object.- Parameters:
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)- Returns:
- index of the first matching Record or -1 if not found
-
findIndex
Find the index of the first Record where property == value in the object.- Parameters:
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)- Returns:
- index of the first matching Record or -1 if not found
-
findNextIndex
LikefindIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.- Parameters:
startIndex
- first index to considerpropertyName
- property to match- Returns:
- index of the first matching Record or -1 if not found
-
findNextIndex
LikefindIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.- Parameters:
startIndex
- first index to considerproperties
- set of properties and values to match- Returns:
- index of the first matching Record or -1 if not found
-
findNextIndex
LikefindIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.- Parameters:
startIndex
- first index to considerpropertyName
- property to matchvalue
- value to compare against (if propertyName is a string)endIndex
- last index to consider- Returns:
- index of the first matching Record or -1 if not found
-
findNextIndex
LikefindIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.- Parameters:
startIndex
- first index to considerpropertyName
- property to matchvalue
- value to compare against (if propertyName is a string)endIndex
- last index to consider- Returns:
- index of the first matching Record or -1 if not found
-
findNextIndex
LikefindIndex(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)].
- Parameters:
startIndex
- first index to considerpropertyName
- property to matchvalue
- value to compare against (if propertyName is a string)endIndex
- last index to consider- Returns:
- index of the first matching Record or -1 if not found
-
findNextIndex
LikefindIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.- Parameters:
startIndex
- first index to considerpropertyName
- property to matchvalue
- value to compare against (if propertyName is a string)endIndex
- last index to consider- Returns:
- index of the first matching Record or -1 if not found
-
findNextIndex
LikefindIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.- Parameters:
startIndex
- first index to considerpropertyName
- property to matchvalue
- value to compare against (if propertyName is a string)endIndex
- last index to consider- Returns:
- index of the first matching Record or -1 if not found
-
findNextIndex
LikefindIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.- Parameters:
startIndex
- first index to considerpropertyName
- property to matchvalue
- value to compare against (if propertyName is a string)endIndex
- last index to consider- Returns:
- index of the first matching Record or -1 if not found
-
find
LikefindIndex(java.util.Map)
, but returns the object itself instead of its index.- Parameters:
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)- Returns:
- first matching object or null if not found
-
find
LikefindIndex(java.util.Map)
, but returns the object itself instead of its index.- Parameters:
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)- Returns:
- first matching object or null if not found
-
find
LikefindIndex(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)].
- Parameters:
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)- Returns:
- first matching object or null if not found
-
find
LikefindIndex(java.util.Map)
, but returns the object itself instead of its index.- Parameters:
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)- Returns:
- first matching object or null if not found
-
findAll
Find all objects where property == value in the object- Parameters:
properties
- set of properties and values to match- Returns:
- all matching Objects or null if none found
-
findAll
Find all objects where property == value in the object.- Parameters:
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)- Returns:
- all matching Objects or null if none found
-
findAll
Find all objects where property == value in the object- Parameters:
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)- Returns:
- all matching Objects or null if none found
-
findAll
Find all objects where property == value in the objectNote: 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)].
- Parameters:
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)- Returns:
- all matching Objects or null if none found
-
findAll
Find all objects where property == value in the object- Parameters:
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)- Returns:
- all matching Objects or null if none found
-
findAll
Find all objects where property == value in the object.- Parameters:
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)- Returns:
- all matching Objects or null if none found
-
findAll
Find all objects where property == value in the object.- Parameters:
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)- Returns:
- all matching Objects or null if none found
-
findAll
Filters all objects according to the AdvancedCriteria passed- Parameters:
adCriteria
- AdvancedCriteria to use to filter results- Returns:
- all matching Objects or null if none found
-
find
Filters all objects according to the AdvancedCriteria passed and returns the first matching object or null if not found- Parameters:
adCriteria
- AdvancedCriteria to use to filter results- Returns:
- first matching object or null if not found
-
findIndex
Finds the index of the first Record that matches with the AdvacendCriteria passed.- Parameters:
adCriteria
- AdvancedCriteria to use to filter results- Returns:
- index of the first matching Record or -1 if not found
-
findNextIndex
LikefindIndex(java.util.Map)
, but considering the startIndex and endIndex parameters.- Parameters:
startIndex
- first index to consideradCriteria
- AdvancedCriteria to use to filter resultsendIndex
- last index to consider- Returns:
- index of the first matching Record or -1 if not found
-
findNextIndex
LikefindIndex(java.util.Map)
, but considering the startIndex parameter.- Parameters:
startIndex
- first index to consideradCriteria
- AdvancedCriteria to use to filter results- Returns:
- index of the first matching Record or -1 if not found
-
contains
Return if this list contains the specified object.- Parameters:
record
- item to look for- Returns:
- true == item was found, false == not found
-
contains
Return if this list contains the specified object.If pos is specified, starts looking after that position.
- Parameters:
record
- item to look forpos
- optional position in the list to look after- Returns:
- true == item was found, false == not found
-
containsAll
Return whether this list contains all the item in the specified list.- Parameters:
list
- items to look for- Returns:
- whether all items were found
-
intersect
Return the list of items that are in both this list and the passed-in list.- Parameters:
list
- list to intersect with- Returns:
- intersection
-
equals
Return whether this list is equal to another 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.
- Parameters:
list
- list to check for equality- Returns:
- whether the specified list is equal to this list
-
getItems
Return the items at a list of specified positions.- Parameters:
itemList
- array of positions- Returns:
- subset of the array, in the same order as itemList
-
getRange
Return the items between position start and end, non-inclusive at the end.- Parameters:
start
- start positionend
- end position- Returns:
- subset of the array from start -> end-1
-
duplicate
Return an Array that is a shallow copy of the list, that is, containing the same items.- Returns:
- new array, pointing to the same items
-
set
Change the array element at a particular position.set() can be used to expand the length of the list.
- Parameters:
pos
- position in the list to changerecord
- new value for that position- Returns:
- whatever's at that position, null if not found
-
addAt
Add a single item to this array at a specific position in the list, sliding other items over to fit.- Parameters:
record
- object to addpos
- position in the list to add at- Returns:
- object that was added
-
removeAt
Remove the item at the specified position, rearranging all subsequent items to fill the gap- Parameters:
pos
- position to remove- Returns:
- item that was removed
-
add
Add an object to this list, at the end- Parameters:
record
- object to add
-
addList
Add a list of items to this array.Note: you can specify that a subset range be added by passing start and end indices
- Parameters:
list
- list of items to add
-
addList
Add a list of items to this array.Note: you can specify that a subset range be added by passing start and end indices
- Parameters:
list
- list of items to addlistStartRow
- optional start index in listlistEndRow
- optional end index in list (non-inclusive)
-
setLength
public void setLength(int length) Set the length of this list.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
.- Parameters:
length
- new length
-
addListAt
Add list of items list to this array at item pos. All items after array[pos] will slide down to fit new items.- Parameters:
list
- new array of itemspos
- position in this list to put the new items
-
remove
Remove first instance of the passed object from this array, sliding other items around to fill gaps.- Parameters:
record
- item to remove- Returns:
- true if a matching object was found and removed, false if no matching object was found and the list remains unchanged.
-
removeList
Remove all instances of objects in the specified list from this list, sliding the remaining objects around to fill gaps.- Parameters:
list
- list of items to remove
-
sort
public void sort()Sorts the elements of the List in place.The optional comparator function should take two parameters "a" and "b" which are the two list items to compare, and should return:
- a value less than zero, if "a" is less than "b" such that "a" should appear earlier in the list
- zero, if "a" and "b" are equal
- a value greater than zero, if "a" is greater than "b" such that "b" should appear earlier in the list
-
sort
Sorts the elements of the List in place.The optional comparator function should take two parameters "a" and "b" which are the two list items to compare, and should return:
- a value less than zero, if "a" is less than "b" such that "a" should appear earlier in the list
- zero, if "a" and "b" are equal
- a value greater than zero, if "a" is greater than "b" such that "b" should appear earlier in the list
- Parameters:
comparator
- comparator function to use- Returns:
- the list itself
-
getProperty
Return a new Array where the value of item i is the value of "property" of item i in this array. If an item doesn't have that property or is null, return item will be null.- Parameters:
property
- name of the property to look for- Returns:
- array of the values of property in each item of this list
-
sortByProperty
Sort a list of objects by a given property of each item.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
- Parameters:
property
- name of the property to sort byup
- true == sort ascending, false == sort descending- Returns:
- the list itself
-
sortByProperty
Sort this ResultSet by a property of each record.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
- Parameters:
property
- name of the property to sort byup
- true == sort ascending, false == sort descendingnormalizer
- May be specified as a callbac with signaturenormalize(item, propertyName)
, whereitem
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.
-
setSort
Multi-Property sort. Sort this ResultSet by a list ofSortSpecifier
's.- Parameters:
sortSpecifiers
- a list ofSortSpecifier
objects, one per sort-field and direction
-
getValueMap
Get a map of the form{ item[idField] -> item[displayField] }
, for all items in the list. Note that if more than one item has the sameidProperty
, the value for the later item in the list will clobber the value for the earlier item.- Parameters:
idField
- Property to use as ID (data value) in the valueMapdisplayField
- Property to use a display value in the valueMap- Returns:
- valueMap object
-
addDataChangedHandler
Add a DataChanged 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
- Specified by:
addDataChangedHandler
in interfaceHasDataChangedHandlers
- Parameters:
handler
- the DataChanged handler- Returns:
HandlerRegistration
used to remove this handler
-
toArray
Returns the records in this RecordList as an array.- Returns:
- an array of records.
-
getRangeList
Return a RecordList with the items between position start and end, non-inclusive at the end.- Parameters:
start
- start positionend
- end position- Returns:
- a RecordList with the items from start -> end-1
-