API  0.9.6
 All Classes Files Functions Variables Macros Modules Pages
CPExpression Class Reference

CPExpression is used to represent expressions in a predicate. More...

#import <CPExpression.h>

+ Inheritance diagram for CPExpression:

Instance Methods

(CPArray- arguments
 
(id) - collection
 
(id) - constantValue
 
(int) - expressionType
 
(CPString- function
 
(id) - initWithExpressionType:
 
(CPString- keyPath
 
(CPExpression- leftExpression
 
(CPExpression- operand
 
(CPPredicate- predicate
 
(CPExpression- rightExpression
 
(CPString- variable
 
- Instance Methods inherited from CPObject
(void) - addObserver:forKeyPath:options:context:
 
(void) - applyChange:toKeyPath:
 
(id) - autorelease
 
(id) - awakeAfterUsingCoder:
 
(void) - awakeFromCib
 
(void) - bind:toObject:withKeyPath:options:
 
(Class) - classForCoder
 
(Class) - classForKeyedArchiver
 
(CPString- className
 
(id) - copy
 
(void) - dealloc
 
(CPString- description
 
(CPDictionary- dictionaryWithValuesForKeys:
 
(void) - didChange:valuesAtIndexes:forKey:
 
(void) - didChangeValueForKey:
 
(void) - didChangeValueForKey:withSetMutation:usingObjects:
 
(void) - doesNotRecognizeSelector:
 
(CPArray- exposedBindings
 
(id) - forwardingTargetForSelector:
 
(void) - forwardInvocation:
 
(unsigned) - hash
 
(BOOL) - implementsSelector:
 
(CPDictionary- infoForBinding:
 
(id) - init
 
(BOOL) - isEqual:
 
(BOOL) - isKindOfClass:
 
(BOOL) - isMemberOfClass:
 
(BOOL) - isProxy
 
(IMP) - methodForSelector:
 
(CPMethodSignature) - methodSignatureForSelector:
 
(id) - mutableArrayValueForKey:
 
(id) - mutableArrayValueForKeyPath:
 
(id) - mutableCopy
 
(id) - mutableSetValueForKey:
 
(id) - mutableSetValueForKeyPath:
 
(id) - performSelector:
 
(id) - performSelector:withObject:
 
(id) - performSelector:withObject:withObject:
 
(id) - performSelector:withObjects:
 
(void) - release
 
(void) - removeObserver:forKeyPath:
 
(id) - replacementObjectForArchiver:
 
(id) - replacementObjectForCoder:
 
(id) - replacementObjectForKeyedArchiver:
 
(BOOL) - respondsToSelector:
 
(id) - retain
 
(id) - self
 
(void) - setValue:forKey:
 
(void) - setValue:forKeyPath:
 
(void) - setValue:forUndefinedKey:
 
(void) - setValuesForKeysWithDictionary:
 
(CPString- UID
 
(void) - unbind:
 
(Class) - valueClassForBinding:
 
(id) - valueForKey:
 
(id) - valueForKeyPath:
 
(id) - valueForUndefinedKey:
 
(void) - willChange:valuesAtIndexes:forKey:
 
(void) - willChangeValueForKey:
 
(void) - willChangeValueForKey:withSetMutation:usingObjects:
 

Class Methods

(CPExpression+ expressionForAggregate:
 
(CPExpression+ expressionForConstantValue:
 
(CPExpression+ expressionForEvaluatedObject
 
(CPExpression+ expressionForFunction:arguments:
 
(CPExpression+ expressionForFunction:selectorName:arguments:
 
(CPExpression+ expressionForIntersectSet:with:
 
(CPExpression+ expressionForKeyPath:
 
(CPExpression+ expressionForMinusSet:with:
 
(CPExpression+ expressionForSubquery:usingIteratorVariable:predicate:
 
(CPExpression+ expressionForUnionSet:with:
 
(CPExpression+ expressionForVariable:
 
- Class Methods inherited from CPObject
(BOOL) + accessInstanceVariablesDirectly
 
(id) + alloc
 
(id) + allocWithCoder:
 
(BOOL) + automaticallyNotifiesObserversForKey:
 
(Class) + class
 
(void) + exposeBinding:
 
(void) + initialize
 
(IMP) + instanceMethodForSelector:
 
(BOOL) + instancesRespondToSelector:
 
(BOOL) + isSubclassOfClass:
 
(CPSet+ keyPathsForValuesAffectingValueForKey:
 
(void) + load
 
(id) + new
 
(void) + setVersion:
 
(Class) + superclass
 
(int) + version
 

Additional Inherited Members

- Instance Variables inherited from CPObject
Class isa
 

Detailed Description

CPExpression is used to represent expressions in a predicate.

Comparison operations in an CPPredicate are based on two expressions, as represented by instances of the CPExpression class. Expressions are created for constant values, key paths, and so on.

Generally, anywhere in the CPExpression class hierarchy where there is composite API and subtypes that may only reasonably respond to a subset of that API, invoking a method that does not make sense for that subtype will cause an exception to be thrown.

Definition at line 2 of file CPExpression.h.

Method Documentation

- (CPArray) arguments
implementation

Returns the arguments for the receiver.

Returns
The arguments for the receiver—that is, the array of expressions that will be passed as parameters during invocation of the selector on the operand of a function expression. This method raises an exception if it is not applicable to the receiver.

Definition at line 317 of file CPExpression.j.

- (id) collection
implementation

Returns the collection of expressions in an aggregate expression, or the collection element of a subquery expression.

Returns
The collection of expressions in an aggregate expression, or the collection element of a subquery expression. This method raises an exception if it is not applicable to the receiver.

Definition at line 328 of file CPExpression.j.

- (id) constantValue
implementation

Returns the constant value of the receiver.

Returns
The constant value of the receiver. This method raises an exception if it is not applicable to the receiver.

Definition at line 273 of file CPExpression.j.

+ (CPExpression) expressionForAggregate: (CPArray collection
implementation

Returns a new aggregate expression for a given collection.

Parameters
collectionA collection object (an instance of CPArray, CPSet, or CPDictionary) that contains further expressions.
Returns
A new expression that contains the expressions in collection.

Definition at line 140 of file CPExpression.j.

+ (CPExpression) expressionForConstantValue: (id)  value
implementation

Returns a new expression that represents a given constant value.

Parameters
valueThe constant value the new expression is to represent.
Returns
A new expression that represents the constant value.

Definition at line 101 of file CPExpression.j.

+ (CPExpression) expressionForEvaluatedObject
implementation

Returns a new expression that represents the object being evaluated.

Returns
A new expression that represents the object being evaluated.

Definition at line 110 of file CPExpression.j.

+ (CPExpression) expressionForFunction: (CPString function_name
arguments: (CPArray parameters 
implementation

Returns a new expression that will invoke one of the predefined functions.

Parameters
function_nameThe name of the function to invoke.
parametersAn array containing CPExpression objects that will be used as parameters during the invocation of selector.
Returns
A new expression that invokes the function name using the parameters in parameters.

For a selector taking no parameters, the array should be empty. For a selector taking one or more parameters, the array should contain one CPExpression object which will evaluate to an instance of the appropriate type for each parameter.

If there is a mismatch between the number of parameters expected and the number you provide during evaluation, an exception may be raised or missing parameters may simply be replaced by nil (which occurs depends on how many parameters are provided, and whether you have over- or underflow).

The name parameter can be one of the following predefined functions:

    name              parameter array contents                           returns
   -------------------------------------------------------------------------------------------------------------------------------------
    sum:              CPExpression instances representing numbers        CPNumber
    count:            CPExpression instances representing numbers        CPNumber
    min:              CPExpression instances representing numbers        CPNumber
    max:              CPExpression instances representing numbers        CPNumber
    average:          CPExpression instances representing numbers        CPNumber
    median:           CPExpression instances representing numbers        CPNumber
    mode:             CPExpression instances representing numbers        CPArray     (returned array will contain all occurrences of the mode)
    stddev:           CPExpression instances representing numbers        CPNumber
    add:to:           CPExpression instances representing numbers        CPNumber
    from:subtract:    two CPExpression instances representing numbers    CPNumber
    multiply:by:      two CPExpression instances representing numbers    CPNumber
    divide:by:        two CPExpression instances representing numbers    CPNumber
    modulus:by:       two CPExpression instances representing numbers    CPNumber
    sqrt:             one CPExpression instance representing numbers     CPNumber
    log:              one CPExpression instance representing a number    CPNumber
    ln:               one CPExpression instance representing a number    CPNumber
    raise:toPower:    one CPExpression instance representing a number    CPNumber
    exp:              one CPExpression instance representing a number    CPNumber
    floor:            one CPExpression instance representing a number    CPNumber
    ceiling:          one CPExpression instance representing a number    CPNumber
    abs:              one CPExpression instance representing a number    CPNumber
    trunc:            one CPExpression instance representing a number    CPNumber
    uppercase:        one CPExpression instance representing a string    CPString
    lowercase:        one CPExpression instance representing a string    CPString
    random:           one CPExpression instance representing a number    CPNumber (integer) such that 0 <= rand < param
    now:               none                                               [CPDate now]

    This method raises an exception immediately if the selector is invalid; it raises an exception at runtime if the parameters are incorrect.

Definition at line 226 of file CPExpression.j.

+ (CPExpression) expressionForFunction: (CPExpression target
selectorName: (CPString selectorName
arguments: (CPArray parameters 
implementation

Returns an expression which will return the result of invoking on a given target a selector with a given name using given arguments.

Parameters
targetA CPExpression object which will evaluate an object on which the selector identified by name may be invoked.
selectorNameThe name of the method to be invoked.
parametersAn array containing CPExpression objects which can be evaluated to provide parameters for the method specified by name.
Returns
An expression which will return the result of invoking the selector named name on the result of evaluating the target expression with the parameters specified by evaluating the elements of parameters.

See the description of expressionForFunction:arguments: for examples of how to construct the parameter array.

Definition at line 240 of file CPExpression.j.

+ (CPExpression) expressionForIntersectSet: (CPExpression left
with: (CPExpression right 
implementation

Returns a new CPExpression object that represent the intersection of a given set and collection.

Parameters
leftAn expression that evaluates to a CPSet object.
rightAn expression that evaluates to a collection object (an instance of CPArray, CPSet, or CPDictionary).
Returns
A new CPExpression object that represents the intersection of left and right.

Definition at line 162 of file CPExpression.j.

+ (CPExpression) expressionForKeyPath: (CPString keyPath
implementation

Returns a new expression that invokes valueForKeyPath: with a given key path.

Parameters
keyPathThe key path that the new expression should evaluate.
Returns
A new expression that invokes valueForKeyPath: with keyPath.

Definition at line 130 of file CPExpression.j.

+ (CPExpression) expressionForMinusSet: (CPExpression left
with: (CPExpression right 
implementation

Returns a new CPExpression object that represent the subtraction of a given collection from a given set.

Parameters
leftAn expression that evaluates to a CPSet object.
leftAn expression that evaluates to a collection object (an instance of CPArray, CPSet, or CPDictionary).
Returns
A new CPExpression object that represents the subtraction of right from left.

Definition at line 173 of file CPExpression.j.

+ (CPExpression) expressionForSubquery: (CPExpression expression
usingIteratorVariable: (CPString variable
predicate: (CPPredicate predicate 
implementation

Returns an expression that filters a collection by storing elements in the collection in a given variable and keeping the elements for which qualifier returns true.

Parameters
expressionA CPExpression that evaluates to a collection.
variableUsed as a local variable, and will shadow any instances of variable in the bindings dictionary. The variable is removed or the old value replaced once evaluation completes.
predicateThe predicate used to determine whether the element belongs in the result collection.
Returns
An expression that filters a collection by storing elements in the collection in the variable variable and keeping the elements for which qualifier returns true.

Definition at line 252 of file CPExpression.j.

+ (CPExpression) expressionForUnionSet: (CPExpression left
with: (CPExpression right 
implementation

Returns a new CPExpression object that represent the union of a given set and collection.

Parameters
leftAn expression that evaluates to a CPSet object.
rightAn expression that evaluates to a collection object (an instance of CPArray, CPSet, or CPDictionary).
Returns
A new CPExpression object that represents the union of left and right.

Definition at line 151 of file CPExpression.j.

+ (CPExpression) expressionForVariable: (CPString string
implementation

Returns a new expression that extracts a value from the variable bindings dictionary for a given key.

Parameters
stringThe key for the variable to extract from the variable bindings dictionary.
Returns
A new expression that extracts from the variable bindings dictionary the value for the key string.

Definition at line 120 of file CPExpression.j.

- (int) expressionType
implementation

Returns the expression type for the receiver.

Returns
The expression type for the receiver. This method raises an exception if it is not applicable to the receiver.

Definition at line 263 of file CPExpression.j.

- (CPString) function
implementation

Returns the function for the receiver.

Returns
The function for the receiver. This method raises an exception if it is not applicable to the receiver.

Definition at line 306 of file CPExpression.j.

- (id) initWithExpressionType: (int)  type
implementation

Initializes the receiver with the specified expression type.

Parameters
typeThe type of the new expression, as defined by CPExpressionType.
Returns
An initialized CPExpression object of the type type.

Definition at line 88 of file CPExpression.j.

- (CPString) keyPath
implementation

Returns the key path for the receiver.

Returns
The key path for the receiver. This method raises an exception if it is not applicable to the receiver.

Definition at line 295 of file CPExpression.j.

- (CPExpression) leftExpression
implementation

Returns the left expression of a set expression.

Returns
The left expression of a set expression. This method raises an exception if it is not applicable to the receiver.

Definition at line 361 of file CPExpression.j.

- (CPExpression) operand
implementation

Returns the operand for the receiver.

Returns
The operand for the receiver—that is, the object on which the selector will be invoked. This method raises an exception if it is not applicable to the receiver.

Definition at line 350 of file CPExpression.j.

- (CPPredicate) predicate
implementation

Returns the predicate in a subquery expression.

Returns
The predicate in a subquery expression.. This method raises an exception if it is not applicable to the receiver.

Definition at line 339 of file CPExpression.j.

- (CPExpression) rightExpression
implementation

Returns the right expression of a set expression.

Returns
The right expression of a set expression. This method raises an exception if it is not applicable to the receiver.

Definition at line 372 of file CPExpression.j.

- (CPString) variable
implementation

Returns the variable for the receiver.

Returns
The variable for the receiver. This method raises an exception if it is not applicable to the receiver.

Definition at line 284 of file CPExpression.j.


The documentation for this class was generated from the following files: