|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.smartgwt.client.core.BaseClass
com.smartgwt.client.data.RecordList
public class RecordList
An an ordered collection of Records.
This class is expected by list-oriented display components such as the ListGrid.
Field Summary | |
---|---|
protected JavaScriptObject |
jsObj
|
Fields inherited from class com.smartgwt.client.core.BaseClass |
---|
config, id, scClassName |
Constructor Summary | |
---|---|
RecordList()
Construct a RecordList with no initial data. |
|
RecordList(JavaScriptObject jsObj)
|
|
RecordList(Record[] data)
Construct a RecordList with initial data. |
Method Summary | |
---|---|
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. |
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. |
Boolean |
contains(Record record)
Return if this list contains the specified object. |
Boolean |
contains(Record record,
int pos)
Return if this list contains the specified object. |
Boolean |
containsAll(RecordList list)
Return whether this list contains all the item in the specified list. |
protected JavaScriptObject |
create()
|
Record[] |
duplicate()
Return an Array that is a shallow copy of the list, that is, containing the same items. |
Boolean |
equals(RecordList list)
Return whether this list is equal to another list. |
Record |
find(String propertyName,
boolean value)
Like findIndex(java.util.Map) , but returns the object itself instead of its index. |
Record |
find(String propertyName,
Date value)
Like findIndex(java.util.Map) , but returns the object itself instead of its index. |
Record |
find(String propertyName,
float value)
Like findIndex(java.util.Map) , but returns the object itself instead of its index. |
Record |
find(String propertyName,
int value)
Like findIndex(java.util.Map) , but returns the object itself instead of its index. |
Record |
find(String propertyName,
String value)
Like findIndex(java.util.Map) , but returns the object itself instead of its index. |
Record[] |
findAll(Map properties)
Find all objects where property == value in the object |
Record[] |
findAll(String propertyName,
boolean value)
Find all objects where property == value in the object. |
Record[] |
findAll(String propertyName,
Date value)
Find all objects where property == value in the object. |
Record[] |
findAll(String propertyName,
float value)
Find all objects where property == value in the object |
Record[] |
findAll(String propertyName,
int value)
Find all objects where property == value in the object |
Record[] |
findAll(String propertyName,
String value)
Find all objects where property == value in the object. |
int |
findIndex(Map properties)
Find the index of the first Record where property == value in the object. |
int |
findIndex(String propertyName,
boolean value)
Find the index of the first Record where property == value in the object. |
int |
findIndex(String propertyName,
Date value)
Find the index of the first Record where property == value in the object. |
int |
findIndex(String propertyName,
float value)
Find the index of the first Record where property == value in the object. |
int |
findIndex(String propertyName,
int value)
Find the index of the first Record where property == value in the object. |
int |
findIndex(String propertyName,
String value)
Find the index of the first Record where property == value in the object. |
int |
findNextIndex(int startIndex,
Map properties)
Like findIndex(java.util.Map) , but inspects a range from startIndex to endIndex. |
int |
findNextIndex(int startIndex,
String propertyName)
Like findIndex(java.util.Map) , but inspects a range from startIndex to endIndex. |
int |
findNextIndex(int startIndex,
String propertyName,
boolean value,
int endIndex)
Like findIndex(java.util.Map) , but inspects a range from startIndex to endIndex. |
int |
findNextIndex(int startIndex,
String propertyName,
Date value,
int endIndex)
Like findIndex(java.util.Map) , but inspects a range from startIndex to endIndex. |
int |
findNextIndex(int startIndex,
String propertyName,
float value,
int endIndex)
Like findIndex(java.util.Map) , but inspects a range from startIndex to endIndex. |
int |
findNextIndex(int startIndex,
String propertyName,
int value,
int endIndex)
Like findIndex(java.util.Map) , but inspects a range from startIndex to endIndex. |
int |
findNextIndex(int startIndex,
String propertyName,
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. |
JavaScriptObject |
getJsObj()
|
int |
getLength()
Return the number of items in this list |
static RecordList |
getOrCreateRef(JavaScriptObject jsObj)
|
Record[] |
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. |
Map |
getValueMap(String idField,
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. |
boolean |
isCreated()
|
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. |
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 |
sort()
Sorts the elements of the List in place. |
RecordList |
sort(Comparator<Record> comparator)
Sorts the elements of the List in place. |
RecordList |
sortByProperty(String property,
boolean up)
Sort a list of objects by a given property of each item. |
Record[] |
toArray()
Returns the records in this RecordList as an array. |
Methods inherited from class com.smartgwt.client.core.BaseClass |
---|
destroy, doAddHandler, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsString, getConfig, getHandlerCount, getID, getOrCreateJsObj, getRef, onInit, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setID, setProperty, setProperty, setProperty, setProperty |
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 Detail |
---|
protected JavaScriptObject jsObj
Constructor Detail |
---|
public RecordList()
public RecordList(Record[] data)
data
- initial Record datapublic RecordList(JavaScriptObject jsObj)
Method Detail |
---|
public static RecordList getOrCreateRef(JavaScriptObject jsObj)
protected JavaScriptObject create()
create
in class BaseClass
public JavaScriptObject getJsObj()
getJsObj
in class BaseClass
public boolean isCreated()
isCreated
in class BaseClass
public Record get(int pos)
pos
- position of the element to get
public int getLength()
public 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 for
public 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 consider
public int lastIndexOf(Record record)
If pos is specified, starts looking before that position.
Returns -1 if not found.
record
- object to look for
public 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 consider
public int findIndex(Map properties)
Note: for string values, matches are case sensitive.
properties
- set of properties and values to match
public int findIndex(String propertyName, 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(String propertyName, int value)
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)
public int findIndex(String propertyName, float value)
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)
public int findIndex(String propertyName, boolean value)
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)
public int findIndex(String propertyName, Date value)
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)
public int findNextIndex(int startIndex, String propertyName)
findIndex(java.util.Map)
, but inspects a range from startIndex to endIndex.
startIndex
- first index to considerpropertyName
- property to match
public int findNextIndex(int startIndex, 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 match
public int findNextIndex(int startIndex, String propertyName, 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 consider
public int findNextIndex(int startIndex, 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 consider
public int findNextIndex(int startIndex, 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 consider
public int findNextIndex(int startIndex, 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 consider
public int findNextIndex(int startIndex, String propertyName, 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 consider
public Record find(String propertyName, String 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(String propertyName, int 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(String propertyName, float 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(String propertyName, 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 find(String propertyName, 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[] findAll(Map properties)
properties
- set of properties and values to
match
public Record[] findAll(String propertyName, String value)
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)
public Record[] findAll(String propertyName, int value)
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)
public Record[] findAll(String propertyName, float value)
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)
public Record[] findAll(String propertyName, boolean value)
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)
public Record[] findAll(String propertyName, Date value)
propertyName
- property to matchvalue
- value to compare against (if propertyName is a string)
public Boolean contains(Record record)
record
- item to look for
public 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 after
public Boolean containsAll(RecordList list)
list
- items to look for
public RecordList intersect(RecordList list)
list
- list to intersect with
public 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 equality
public Record[] getItems(int[] itemList)
itemList
- array of positions
public Record[] getRange(int start, int end)
start
- start positionend
- end position
public 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 position
public Record addAt(Record record, int pos)
record
- object to addpos
- position in the list to add at
public Record removeAt(int pos)
pos
- position to remove
public 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 Boolean remove(Record record)
record
- item to remove
public 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(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 use
public Record[] getProperty(String property)
property
- name of the property to look for
public RecordList sortByProperty(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 descending
public Map getValueMap(String idField, 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 valueMap
public 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 handler
HandlerRegistration
used to remove this handlerpublic Record[] toArray()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |