E
- The class of objects in this listpublic class RealmResults<E extends RealmObject>
extends java.util.AbstractList<E>
RealmQuery.findAll()
,
Realm.allObjects(Class)
Modifier and Type | Field and Description |
---|---|
static boolean |
SORT_ORDER_ASCENDING |
static boolean |
SORT_ORDER_DESCENDING |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E element)
Deprecated.
|
void |
add(int index,
E element)
Deprecated.
|
double |
average(java.lang.String fieldName)
Returns the average of a given field.
|
void |
clear()
Removes all objects from the list.
|
E |
first()
Get the first object from the list.
|
E |
get(int rowIndex) |
int |
indexOf(java.lang.Object o) |
java.util.Iterator<E> |
iterator()
Returns an iterator for the results of a query.
|
E |
last()
Get the last object from the list.
|
java.util.ListIterator<E> |
listIterator()
Returns a list iterator for the results of a query.
|
java.util.ListIterator<E> |
listIterator(int location)
Returns a list iterator on the results of a query.
|
java.lang.Number |
max(java.lang.String fieldName)
Find the maximum value of a field.
|
java.util.Date |
maxDate(java.lang.String fieldName)
Find the maximum date.
|
java.lang.Number |
min(java.lang.String fieldName)
Find the minimum value of a field.
|
java.util.Date |
minDate(java.lang.String fieldName)
Find the minimum date.
|
E |
remove(int index)
Removes an object at a given index.
|
void |
removeLast()
Removes the last object in the list.
|
int |
size() |
void |
sort(java.lang.String fieldName)
Sort (ascending) an existing @{link io.realm.RealmResults}.
|
void |
sort(java.lang.String[] fieldNames,
boolean[] sortAscending)
Sort existing @{link io.realm.RealmResults}.
|
void |
sort(java.lang.String fieldName,
boolean sortAscending)
Sort existing @{link io.realm.RealmResults}.
|
void |
sort(java.lang.String fieldName1,
boolean sortAscending1,
java.lang.String fieldName2,
boolean sortAscending2)
Sort existing {link io.realm.RealmResults} using two fields.
|
void |
sort(java.lang.String fieldName1,
boolean sortAscending1,
java.lang.String fieldName2,
boolean sortAscending2,
java.lang.String fieldName3,
boolean sortAscending3)
Sort existing {link io.realm.RealmResults} using three fields.
|
java.lang.Number |
sum(java.lang.String fieldName)
Calculate the sum of a given field.
|
RealmQuery<E> |
where()
Returns a typed @{link io.realm.RealmQuery}, which can be used to query for specific
objects of this type.
|
addAll, equals, hashCode, lastIndexOf, removeRange, set, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
public static final boolean SORT_ORDER_ASCENDING
public static final boolean SORT_ORDER_DESCENDING
public RealmQuery<E> where()
RealmQuery
public E get(int rowIndex)
get
in interface java.util.List<E extends RealmObject>
get
in class java.util.AbstractList<E extends RealmObject>
public int indexOf(java.lang.Object o)
indexOf
in interface java.util.List<E extends RealmObject>
indexOf
in class java.util.AbstractList<E extends RealmObject>
public E first()
public E last()
public java.util.Iterator<E> iterator()
ConcurrentModificationException
if accessed.iterator
in interface java.lang.Iterable<E extends RealmObject>
iterator
in interface java.util.Collection<E extends RealmObject>
iterator
in interface java.util.List<E extends RealmObject>
iterator
in class java.util.AbstractList<E extends RealmObject>
Iterator
public java.util.ListIterator<E> listIterator()
ConcurrentModificationException
if accessed.listIterator
in interface java.util.List<E extends RealmObject>
listIterator
in class java.util.AbstractList<E extends RealmObject>
ListIterator
public java.util.ListIterator<E> listIterator(int location)
ConcurrentModificationException
if accessed.listIterator
in interface java.util.List<E extends RealmObject>
listIterator
in class java.util.AbstractList<E extends RealmObject>
location
- the index at which to start the iteration.java.lang.IndexOutOfBoundsException
- if location < 0 || location > size()
ListIterator
public void sort(java.lang.String fieldName)
fieldName
- The field name to sort by. Only fields of type boolean, short, int, long,
float, double, Date, and String are supported.java.lang.IllegalArgumentException
- if field name does not exist.public void sort(java.lang.String fieldName, boolean sortAscending)
fieldName
- The field name to sort by. Only fields of type boolean, short, int,
long, float, double, Date, and String are supported.sortAscending
- The direction to sort by; if true ascending, otherwise descending
You can use the constants SORT_ORDER_ASCENDING and SORT_ORDER_DESCENDING
for readability.java.lang.IllegalArgumentException
- if field name does not exist.public void sort(java.lang.String[] fieldNames, boolean[] sortAscending)
fieldNames
- an array of field names to sort by. Only fields of type boolean, short, int,
long, float, double, Date, and String are supported.sortAscending
- The directions to sort by; if true ascending, otherwise descending
You can use the constants SORT_ORDER_ASCENDING and SORT_ORDER_DESCENDING
for readability.java.lang.IllegalArgumentException
- if a field name does not exist.public void sort(java.lang.String fieldName1, boolean sortAscending1, java.lang.String fieldName2, boolean sortAscending2)
fieldName1
- first field name.sortAscending1
- sort order for first field.fieldName2
- second field name.sortAscending2
- sort order for second field.java.lang.IllegalArgumentException
- if a field name does not exist.public void sort(java.lang.String fieldName1, boolean sortAscending1, java.lang.String fieldName2, boolean sortAscending2, java.lang.String fieldName3, boolean sortAscending3)
fieldName1
- first field name.sortAscending1
- sort order for first field.fieldName2
- second field name.sortAscending2
- sort order for second field.fieldName3
- third field name.sortAscending3
- sort order for third field.java.lang.IllegalArgumentException
- if a field name does not exist.public int size()
size
in interface java.util.Collection<E extends RealmObject>
size
in interface java.util.List<E extends RealmObject>
size
in class java.util.AbstractCollection<E extends RealmObject>
public java.lang.Number min(java.lang.String fieldName)
fieldName
- The field to look for a minimum on. Only int, float, and double
are supported.java.lang.IllegalArgumentException
- if field is not int, float or double.public java.util.Date minDate(java.lang.String fieldName)
fieldName
- The field to look for the minimum date. If fieldName is not of Date type,
an exception is thrown.java.lang.IllegalArgumentException
- if fieldName is not a Date field.public java.lang.Number max(java.lang.String fieldName)
fieldName
- The field to look for a maximum on. Only int, float, and double are supported.java.lang.IllegalArgumentException
- if field is not int, float or double.public java.util.Date maxDate(java.lang.String fieldName)
fieldName
- The field to look for the maximum date. If fieldName is not of Date type,
an exception is thrown.java.lang.IllegalArgumentException
- if fieldName is not a Date field.public java.lang.Number sum(java.lang.String fieldName)
fieldName
- The field to sum. Only int, float, and double are supported.java.lang.IllegalArgumentException
- if field is not int, float or double.public double average(java.lang.String fieldName)
fieldName
- The field to calculate average on. Only properties of type int,
float and double are supported.java.lang.IllegalArgumentException
- if field is not int, float or double.public E remove(int index)
remove
in interface java.util.List<E extends RealmObject>
remove
in class java.util.AbstractList<E extends RealmObject>
index
- The array index identifying the object to be removed.public void removeLast()
public void clear()
clear
in interface java.util.Collection<E extends RealmObject>
clear
in interface java.util.List<E extends RealmObject>
clear
in class java.util.AbstractList<E extends RealmObject>
@Deprecated public boolean add(E element)
add
in interface java.util.Collection<E extends RealmObject>
add
in interface java.util.List<E extends RealmObject>
add
in class java.util.AbstractList<E extends RealmObject>
@Deprecated public void add(int index, E element)
add
in interface java.util.List<E extends RealmObject>
add
in class java.util.AbstractList<E extends RealmObject>