org.josql.functions
Class GroupingFunctions

java.lang.Object
  extended by org.josql.functions.AbstractFunctionHandler
      extended by org.josql.functions.GroupingFunctions
All Implemented Interfaces:
FunctionHandler

public class GroupingFunctions
extends AbstractFunctionHandler


Field Summary
static String HANDLER_ID
           
static String VALUE
           
 
Fields inherited from class org.josql.functions.AbstractFunctionHandler
q
 
Constructor Summary
GroupingFunctions()
           
 
Method Summary
 Double avg(Expression exp)
           
 Double avg(List allobjs, Expression exp)
           
 Double avg(List allobjs, Expression exp, String saveValueName)
           
 void checkType(Object o, Class expected, Expression exp)
           
 String concat(Expression exp)
           
 String concat(List allobjs, Expression exp)
           
 String concat(List allobjs, Expression exp, String sep)
           
 String concat(List allobjs, Expression exp, String sep, String saveValueName)
           
 Object greatest(List allobjs, Expression exp)
           
 Object greatest(List allobjs, Expression exp, String saveValueName)
           
 Object greatestObject(List allobjs, Expression exp)
           
 Object least(List allobjs, Expression exp)
           
 Object least(List allobjs, Expression exp, String saveValueName)
           
 Object leastObject(List allobjs, Expression exp)
           
 Object max(Expression exp)
           
 Object max(List allobjs, Expression exp)
           
 Object max(List allobjs, Expression exp, String saveValueName)
           
 Map.Entry maxEntry(Map m, String type)
           
 Object maxObject(Expression exp)
           
 Object maxObject(List allobjs, Expression exp)
           
 Object min(Expression exp)
           
 Object min(List allobjs, Expression exp)
           
 Object min(List allobjs, Expression exp, String saveValueName)
           
 Map.Entry minEntry(Map m, String type)
           
 Map.Entry minEntry(Object m, String type)
           
 Object minObject(Expression exp)
           
 Object minObject(List allobjs, Expression exp)
           
 Map occurrence(List objs)
          A function that will take each item from the passed in List and determine a "count" for each item, i.e.
 Map occurrence(List objs, Expression exp)
          A function that will take each item from the passed in List and determine a "count" for each item, i.e.
 Map occurrence(List objs, Expression exp, Expression limitExp)
          This is the same as occurrence(List,Expression) except that the second expression should evaluate to a number that will be used to limit the results, the occurrence count must be greater than or equal to the value from the expression.
 Double sum(Expression exp)
           
 Double sum(List objs, Expression exp)
           
 Double sum(List allobjs, Expression exp, String saveValueName)
           
 Double sum(List objs, String acc)
          This function allows you to specify your own accessor as a string that will be used to access the relevant value for each of the objects in the objs List.
 
Methods inherited from class org.josql.functions.AbstractFunctionHandler
setQuery
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VALUE

public static final String VALUE
See Also:
Constant Field Values

HANDLER_ID

public static final String HANDLER_ID
See Also:
Constant Field Values
Constructor Detail

GroupingFunctions

public GroupingFunctions()
Method Detail

least

public Object least(List allobjs,
                    Expression exp,
                    String saveValueName)
             throws QueryExecutionException
Throws:
QueryExecutionException

minObject

public Object minObject(Expression exp)
                 throws QueryExecutionException
Throws:
QueryExecutionException

minObject

public Object minObject(List allobjs,
                        Expression exp)
                 throws QueryExecutionException
Throws:
QueryExecutionException

leastObject

public Object leastObject(List allobjs,
                          Expression exp)
                   throws QueryExecutionException
Throws:
QueryExecutionException

maxObject

public Object maxObject(List allobjs,
                        Expression exp)
                 throws QueryExecutionException
Throws:
QueryExecutionException

maxObject

public Object maxObject(Expression exp)
                 throws QueryExecutionException
Throws:
QueryExecutionException

greatestObject

public Object greatestObject(List allobjs,
                             Expression exp)
                      throws QueryExecutionException
Throws:
QueryExecutionException

least

public Object least(List allobjs,
                    Expression exp)
             throws QueryExecutionException
Throws:
QueryExecutionException

min

public Object min(Expression exp)
           throws QueryExecutionException
Throws:
QueryExecutionException

min

public Object min(List allobjs,
                  Expression exp)
           throws QueryExecutionException
Throws:
QueryExecutionException

min

public Object min(List allobjs,
                  Expression exp,
                  String saveValueName)
           throws QueryExecutionException
Throws:
QueryExecutionException

maxEntry

public Map.Entry maxEntry(Map m,
                          String type)

minEntry

public Map.Entry minEntry(Object m,
                          String type)
                   throws QueryExecutionException
Throws:
QueryExecutionException

minEntry

public Map.Entry minEntry(Map m,
                          String type)

max

public Object max(List allobjs,
                  Expression exp,
                  String saveValueName)
           throws QueryExecutionException
Throws:
QueryExecutionException

greatest

public Object greatest(List allobjs,
                       Expression exp,
                       String saveValueName)
                throws QueryExecutionException
Throws:
QueryExecutionException

greatest

public Object greatest(List allobjs,
                       Expression exp)
                throws QueryExecutionException
Throws:
QueryExecutionException

max

public Object max(Expression exp)
           throws QueryExecutionException
Throws:
QueryExecutionException

max

public Object max(List allobjs,
                  Expression exp)
           throws QueryExecutionException
Throws:
QueryExecutionException

checkType

public void checkType(Object o,
                      Class expected,
                      Expression exp)
               throws QueryExecutionException
Throws:
QueryExecutionException

sum

public Double sum(List allobjs,
                  Expression exp,
                  String saveValueName)
           throws QueryExecutionException
Throws:
QueryExecutionException

sum

public Double sum(Expression exp)
           throws QueryExecutionException
Throws:
QueryExecutionException

sum

public Double sum(List objs,
                  Expression exp)
           throws QueryExecutionException
Throws:
QueryExecutionException

sum

public Double sum(List objs,
                  String acc)
           throws QueryExecutionException
This function allows you to specify your own accessor as a string that will be used to access the relevant value for each of the objects in the objs List.

Parameters:
objs - The List of objects you wish to sum over.
acc - The accessor to create for accessing the value in each of the objects in objs.
Returns:
The summed value.
Throws:
QueryExecutionException - If the accessor is not valid for the objects in the list or if the accessor throws an exception.

concat

public String concat(List allobjs,
                     Expression exp,
                     String sep,
                     String saveValueName)
              throws QueryExecutionException
Throws:
QueryExecutionException

concat

public String concat(List allobjs,
                     Expression exp,
                     String sep)
              throws QueryExecutionException
Throws:
QueryExecutionException

concat

public String concat(Expression exp)
              throws QueryExecutionException
Throws:
QueryExecutionException

concat

public String concat(List allobjs,
                     Expression exp)
              throws QueryExecutionException
Throws:
QueryExecutionException

avg

public Double avg(List allobjs,
                  Expression exp,
                  String saveValueName)
           throws QueryExecutionException
Throws:
QueryExecutionException

avg

public Double avg(Expression exp)
           throws QueryExecutionException
Throws:
QueryExecutionException

avg

public Double avg(List allobjs,
                  Expression exp)
           throws QueryExecutionException
Throws:
QueryExecutionException

occurrence

public Map occurrence(List objs)
               throws QueryExecutionException
A function that will take each item from the passed in List and determine a "count" for each item, i.e. how many times each item appears.

Parameters:
objs - The List of objects to operate on.
Returns:
A Map of object to a count of the number of times the object appears in the list.
Throws:
QueryExecutionException - Won't happen in this method.

occurrence

public Map occurrence(List objs,
                      Expression exp)
               throws QueryExecutionException
A function that will take each item from the passed in List and determine a "count" for each item, i.e. how many times each item appears.

Parameters:
objs - The List of objects to operate on.
exp - An optional expression that should be performed on each object and the value returned used instead.
Returns:
A Map of object to a count of the number of times the object appears in the list.
Throws:
QueryExecutionException - If the expression cannot be evaluated.

occurrence

public Map occurrence(List objs,
                      Expression exp,
                      Expression limitExp)
               throws QueryExecutionException
This is the same as occurrence(List,Expression) except that the second expression should evaluate to a number that will be used to limit the results, the occurrence count must be greater than or equal to the value from the expression.

Parameters:
objs - The List of objects to operate on.
exp - An optional expression that should be performed on each object and the value returned used instead.
limitExp - An expression that when evaluated should return a number, this will then be used to limit the results returned to those that have an occurrence count >= that number.
Returns:
A Map of object to a count of the number of times the object appears in the list.
Throws:
QueryExecutionException - If the expression cannot be evaluated or the limitExp arg does not evaulate to a number.


  Copyright © 2008 Gary Bentley. All Rights Reserved.