| 
WebObjects 5.4.2 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public static interface NSArray.Operator
Objects implementing NSArray.Operator are used to perform operations on an array's elements.
 To compute an operation on an array's elements, the key-value coding methods with a specially formatted key are used. The character @ introduces the name of the operator to be performed. For
 example, to compute the average salary of an array's elements, the method valueForKeyPath can be used with "@avg.salary" as key path.
 
 The new operator class can be made available for use with NSArrays with the method setOperatorForKey. The operatorNames method returns the keys for the operators
 that NSArray knows about, and operatorForKey returns the operator for a specified key.
NSArray.Operator.compute(com.webobjects.foundation.NSArray, java.lang.String), 
NSArray.valueForKeyPath(java.lang.String), 
NSArray.operatorForKey(java.lang.String), 
NSArray.setOperatorForKey(java.lang.String, com.webobjects.foundation.NSArray.Operator), 
NSArray| Method Summary | |
|---|---|
 Object | 
compute(NSArray values,
        String keyPath)
This interface must be implemented in order to add new operators to NSArray.  | 
| Method Detail | 
|---|
Object compute(NSArray values,
               String keyPath)
         <blockquote>
          class CountOperator implements NSArray.Operator {
              CountOperator() {}
              public Object compute(NSArray values, String keyPath) {
                  return new Integer(values.count());
              }
          }
          </blockquote>
 
 
 Performs an operation on the elements in values and returns the result. The keyPath argument optionally specifies a particular property of the elements in values to perform
 the operation on.
values - array of input objectskeyPath - property of the elements in values to perform the operation on
  | 
Last updated June 2008 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||