Package | com.smartfoxserver.v2.entities.match |
Class | public class MatchExpression |
Inheritance | MatchExpression Object |
The matching expressions are built like "if" statements 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: in fact a matching expression can compare predefined properties of the Room and user entities (see the RoomProperties and UserProperties classes), but also custom Room or User Variables.
These expressions are easy to create and concatenate, and they can be used for many different filtering operations within the SmartFoxServer 2X framework, for example to invite players to join a game (see the CreateSFSGameRequest request description), to look for specific Rooms or users (see the FindRoomsRequest and FindUsersRequest requests descriptions), etc.
Additionally (see the examples for more informations):
See also
Property | Defined By | ||
---|---|---|---|
condition : IMatcher [read-only]
Returns the matching criteria used during values comparison. | MatchExpression | ||
logicOp : LogicOperator [read-only]
In case of concatenated expressions, returns the current logical operator. | MatchExpression | ||
next : MatchExpression [read-only]
Returns the next matching expression concatenated to the current one. | MatchExpression | ||
value : * [read-only]
Returns the value against which the variable or property corresponding to varName is compared. | MatchExpression | ||
varName : String [read-only]
Returns the name of the variable or property against which the comparison is made. | MatchExpression |
Method | Defined By | ||
---|---|---|---|
MatchExpression(varName:String, condition:IMatcher, value:*)
Creates a new MatchExpression instance. | MatchExpression | ||
Concatenates the current expression with a new one using the logical AND operator. | MatchExpression | ||
hasNext():Boolean
Checks if the current matching expression is concatenated to another one through a logical operator. | MatchExpression | ||
Concatenates the current expression with a new one using the logical OR operator. | MatchExpression | ||
Moves the iterator cursor to the first matching expression in the chain. | MatchExpression | ||
toString():String
Returns a string representation of the matching expression. | MatchExpression |
condition | property |
condition:IMatcher
[read-only] Returns the matching criteria used during values comparison.
Different objects implementing the IMatcher interface can be used, depending on the type of the variable or property to check.
public function get condition():IMatcher
See also
logicOp | property |
logicOp:LogicOperator
[read-only] In case of concatenated expressions, returns the current logical operator.
The default value is null
.
public function get logicOp():LogicOperator
next | property |
next:MatchExpression
[read-only] Returns the next matching expression concatenated to the current one.
public function get next():MatchExpression
value | property |
value:*
[read-only] Returns the value against which the variable or property corresponding to varName is compared.
public function get value():*
varName | property |
varName:String
[read-only] Returns the name of the variable or property against which the comparison is made.
Depending what the matching expression is used for (searching a user or a Room), this can be the name of a User Variable or a Room Variable, or it can be one of the constants contained in the UserProperties or RoomProperties classes, representing some of the predefined properties of the user and Room entities respectively.
public function get varName():String
See also
MatchExpression | () | Constructor |
public function MatchExpression(varName:String, condition:IMatcher, value:*)
Creates a new MatchExpression instance.
ParametersvarName:String — Name of the variable or property to match.
| |
condition:IMatcher — The matching condition.
| |
value:* — The value to compare against the variable or property during the matching.
|
See also
and | () | method |
public function and(varName:String, condition:IMatcher, value:*):MatchExpression
Concatenates the current expression with a new one using the logical AND operator.
Parameters
varName:String — The name of the additional variable or property to match.
| |
condition:IMatcher — The additional matching condition.
| |
value:* — The value to compare against the additional variable or property during the matching.
|
MatchExpression — A new MatchExpression resulting from the concatenation of the current expression with a new one generated from the specified parameters.
|
See also
hasNext | () | method |
public function hasNext():Boolean
Checks if the current matching expression is concatenated to another one through a logical operator.
ReturnsBoolean — true if the current matching expression is concatenated to another one.
|
See also
or | () | method |
public function or(varName:String, condition:IMatcher, value:*):MatchExpression
Concatenates the current expression with a new one using the logical OR operator.
Parameters
varName:String — The name of the additional variable or property to match.
| |
condition:IMatcher — The additional matching condition.
| |
value:* — The value to compare against the additional variable or property during the matching.
|
MatchExpression — A new MatchExpression resulting from the concatenation of the current expression with a new one generated from the specified parameters.
|
See also
rewind | () | method |
public function rewind():MatchExpression
Moves the iterator cursor to the first matching expression in the chain.
ReturnsMatchExpression — The MatchExpression object at the top of the chain of matching expressions.
|
toString | () | method |
public function toString():String
Returns a string representation of the matching expression.
ReturnsString — The string representation of the MatchExpression object.
|
var exp:MatchExpression = new MatchExpression('rank', NumberMatch.GREATER_THAN, 5).and('country', StringMatch.EQUALS, 'Italy');
var exp:MatchExpression = new MatchExpression(RoomProperties.IS_GAME, BoolMatch.EQUALS, true) .and(RoomProperties.HAS_FREE_PLAYER_SLOTS, BoolMatch.EQUALS, true) .and("isGameStarted", BoolMatch.EQUALS, false);
var exp:MatchExpression = new MatchExpression("avatarData.shield.inUse", BoolMatch.EQUALS, true);
var exp:MatchExpression = new MatchExpression("avatarData.weapons.3.name", StringMatch.EQUALS, "Narsil");