Project Wonder 5.0

er.extensions.foundation
Class ERXArrayUtilities.AvgNonNullOperator

java.lang.Object
  extended by er.extensions.foundation.ERXArrayUtilities.AvgNonNullOperator
All Implemented Interfaces:
com.webobjects.foundation.NSArray.Operator
Enclosing class:
ERXArrayUtilities

public static class ERXArrayUtilities.AvgNonNullOperator
extends java.lang.Object
implements com.webobjects.foundation.NSArray.Operator

Define an NSArray.Operator for the key avgNonNull.

This allows for key value paths like:

which will sum up all values for the key amount and divide by the number of nun-null entries. @avgNonNull applies to the array of objects to its left if it is the last key in the path. Otherwise it applies to the end of the keypath to its right. It should not be followed by an array or any other array operators. This is because it does not call valueForKeyPath on the array to its left, but instead loops through the values of the array to its left, calling valueForKeyPath on the individual array values instead. This behavior is consistent with Apple's standard NSArray operators.


Constructor Summary
ERXArrayUtilities.AvgNonNullOperator()
          public empty constructor
 
Method Summary
 java.lang.Object compute(com.webobjects.foundation.NSArray<?> array, java.lang.String keypath)
          returns the average value for over all non-null values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ERXArrayUtilities.AvgNonNullOperator

public ERXArrayUtilities.AvgNonNullOperator()
public empty constructor

Method Detail

compute

public java.lang.Object compute(com.webobjects.foundation.NSArray<?> array,
                                java.lang.String keypath)
returns the average value for over all non-null values.

Specified by:
compute in interface com.webobjects.foundation.NSArray.Operator
Parameters:
array - array to be checked.
keypath - path to numeric values
Returns:
computed average as BigDecimal or NULL.

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.