query
Class QueryList

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byjava.util.ArrayList
              extended byquery.QueryList
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.util.RandomAccess, java.io.Serializable

public class QueryList
extends java.util.ArrayList

This class extends ArrayList and contains methods to sort and filter.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
QueryList()
           
 
Method Summary
 QueryList filter(Operator operator)
          filters QueryList which contains only those beans which satisfies the operator condition.
 boolean sort(java.lang.String fieldName)
          Overridden method for sorting.
 boolean sort(java.lang.String[] fieldNames, boolean ascending)
          sorts the QueryList by the fieldNames in ascending or descending order.
 boolean sort(java.lang.String[] fieldNames, boolean[] ascending)
          sorts the QueryList by the fieldNames in ascending or descending order.
 boolean sort(java.lang.String fieldName, boolean ascending)
          sorts the QueryList by the fieldName in ascending or descending order.
 boolean sort(java.lang.String fieldName, boolean ascending, boolean ignoreCase)
          sorts the QueryList by the fieldName in ascending or descending order.
 double sum(java.lang.String fieldName)
          calculates the sum of the field in this QueryList.
 double sum(java.lang.String fieldName, java.lang.Class arg, java.lang.Object value)
          calculates the sum of the field in this QueryList.
 double sum(java.lang.String fieldName, Operator operator)
          calculates the sum of the field in this QueryList.
 java.lang.String toString()
          Overridden method of super class, java.util.ArrayList.
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList
 

Constructor Detail

QueryList

public QueryList()
Method Detail

sort

public boolean sort(java.lang.String fieldName)
Overridden method for sorting. By default it will sort in ascending order. sorts the QueryList by the fieldName in ascending or descending order. Note: the field Object should be of Comparable type.

Parameters:
fieldName - field which is used to sort the bean.
Returns:
boolean indicating whether the sort is completed successfully or not.

sort

public boolean sort(java.lang.String fieldName,
                    boolean ascending)
sorts the QueryList by the fieldName in ascending or descending order. Note: the field Objects should be of Comparable type.

Parameters:
fieldName - field which is used to sort the bean.
ascending - if true sorting is done in ascending order, else sorting is done in descending order.
Returns:
boolean indicating whether the sort is completed successfully or not.

sort

public boolean sort(java.lang.String fieldName,
                    boolean ascending,
                    boolean ignoreCase)
sorts the QueryList by the fieldName in ascending or descending order. Note: the field Object should be of Comparable type.

Parameters:
ignoreCase - use only when comparing strings. as default implementation uses case sensitive comparison.
fieldName - field which is used to sort the bean.
ascending - if true sorting is done in ascending order, else sorting is done in descending order.
Returns:
boolean indicating whether the sort is completed successfully or not.

sort

public boolean sort(java.lang.String[] fieldNames,
                    boolean ascending)
sorts the QueryList by the fieldNames in ascending or descending order. Note: the field Objects should be of Comparable type.

Parameters:
fieldNames - fields which is used to sort the bean.
ascending - if true sorting is done in ascending order, else sorting is done in descending order.
Returns:
boolean indicating whether the sort is completed successfully or not. Modified code for the better performance and proper sorting.

sort

public boolean sort(java.lang.String[] fieldNames,
                    boolean[] ascending)
sorts the QueryList by the fieldNames in ascending or descending order. Note: the field Objects should be of Comparable type.

Parameters:
fieldNames - fields which is used to sort the bean.
ascending - if true sorting is done in ascending order, else sorting is done in descending order.
Returns:
boolean indicating whether the sort is completed successfully or not. Modified code for the better performance and proper sorting.

filter

public QueryList filter(Operator operator)
filters QueryList which contains only those beans which satisfies the operator condition.

Parameters:
operator - Operator.
Returns:
QueryList which contains only those beans which satisfies the operator condition.

sum

public double sum(java.lang.String fieldName)
calculates the sum of the field in this QueryList.

Parameters:
fieldName - field of bean whose sum has to be calculated.
Returns:
sum.

sum

public double sum(java.lang.String fieldName,
                  java.lang.Class arg,
                  java.lang.Object value)
calculates the sum of the field in this QueryList.

Parameters:
fieldName - field of bean whose sum has to be calculated.
arg - argument for the getter method of field if it takes any argumnt, else can be null.
value - value for the argument, else can be null.
Returns:
returns sum.

sum

public double sum(java.lang.String fieldName,
                  Operator operator)
calculates the sum of the field in this QueryList.

Parameters:
fieldName - field of bean whose sum has to be calculated.
operator - to get filrtered vector on which sum will be called.
Returns:
returns sum.

toString

public java.lang.String toString()
Overridden method of super class, java.util.ArrayList.

Returns:
string representation of this.