MatchExpression Class Reference
| Inherits from | NSObject |
| Declared in | MatchExpression.h MatchExpression.m |
Overview
Match Expressions are built like “if” conditions in any common programming language.
They work like queries in a database and can be used to search for Rooms or Users using custom criteria. These expressions are extremely easy to create and concatenate and they can be used for many different filtering operations within the SFS2X framework.
This is a quick example:
MatchExpression *exp = [MatchExpression expressionWithVarName:@"rank" condition:[NumberMatch numberMatchGreaterThan] value:[NSNumber numberWithInt:5]];
exp = [exp and:@"country" condition:[StringMatch stringMatchEquals] value:@"Italy"];
Expressions are made of three elements:
- Variable name
- Match operator
- Value
Additionally any number of expressions can be linked together with a logical AND / OR operator, just like in regular code. In the above example we have created an expression that will check for a rank value > 5 and a country value == “Italy”.
The search options are not just limited to User/Room Variables name. In fact the Matching engine provides two extra classes, RoomProperties and UserProperties, where you can access many specific attributes of the Room and User class.
Tasks
-
varNameGet the name of the variable or property that is being matched.
property -
conditionGet the condition used for matching
property -
valueThe value used to test the condition in the expression
property -
logicOpGet the current logic operator, could be null if the expression has no other concatenated expressions
property -
nextGet the next expression chained to the current one.
property -
+ expressionWithVarName:condition:value:name of the variable/property to match
-
– and:condition:value:Concatenate the current expression with a new one using the logical AND operator
-
– or:condition:value:Concatenate the current expression with a new one using the logical OR operator
-
– hasNextCheck if the current expression is concatenated to another one via a logic operator
-
– rewindRewinds the cursor to the first expression in the chain and return the MatchExpression at the top of the chain of expressions
Properties
condition
Get the condition used for matching
@property (nonatomic, retain) id<IMatcher> conditionDiscussion
Get the condition used for matching
See Also
Declared In
MatchExpression.hlogicOp
Get the current logic operator, could be null if the expression has no other concatenated expressions
@property (nonatomic, retain) LogicOperator *logicOpDiscussion
Get the current logic operator, could be null if the expression has no other concatenated expressions
See Also
Declared In
MatchExpression.hnext
Get the next expression chained to the current one.
@property (nonatomic, retain) MatchExpression *nextDiscussion
Get the next expression chained to the current one.
Declared In
MatchExpression.hvalue
The value used to test the condition in the expression
@property (nonatomic, retain) id valueDiscussion
The value used to test the condition in the expression
Declared In
MatchExpression.hvarName
Get the name of the variable or property that is being matched.
@property (nonatomic, retain) NSString *varNameDiscussion
Get the name of the variable or property that is being matched.
This can be the name of a User/Room variable or a property from the classes listed below.
See Also
Declared In
MatchExpression.hClass Methods
expressionWithVarName:condition:value:
name of the variable/property to match
+ (id)expressionWithVarName:(NSString *)varName condition:(id<IMatcher>)condition value:(id)valueParameters
- varName
name of the variable/property to match
- condition
the match condition
- value
the value to match against
Declared In
MatchExpression.hInstance Methods
and:condition:value:
Concatenate the current expression with a new one using the logical AND operator
- (MatchExpression *)and:(NSString *)varName condition:(id<IMatcher>)condition value:(id)valueParameters
- varName
name of the variable/property to match
- condition
the match condition
- value
the value to match against
return a new MatchExpression
Discussion
Concatenate the current expression with a new one using the logical AND operator
Declared In
MatchExpression.hhasNext
Check if the current expression is concatenated to another one via a logic operator
- (BOOL)hasNextDiscussion
Check if the current expression is concatenated to another one via a logic operator
See Also
Declared In
MatchExpression.hor:condition:value:
Concatenate the current expression with a new one using the logical OR operator
- (MatchExpression *)or:(NSString *)varName condition:(id<IMatcher>)condition value:(id)valueParameters
- varName
name of the variable/property to match
- condition
the match condition
- value
the value to match against
return a new MatchExpression
Discussion
Concatenate the current expression with a new one using the logical OR operator
Declared In
MatchExpression.hrewind
Rewinds the cursor to the first expression in the chain and return the MatchExpression at the top of the chain of expressions
- (MatchExpression *)rewindDiscussion
Rewinds the cursor to the first expression in the chain and return the MatchExpression at the top of the chain of expressions
Declared In
MatchExpression.h