| Package | system.evaluators |
| Class | public class PropertyEvaluator |
| Inheritance | PropertyEvaluator Object |
| Implements | Evaluable |
| Subclasses | ConfigEvaluator, LocaleEvaluator |
Example :
import system.evaluators.PropertyEvaluator ;
var obj:Object =
{
message : "hello world" ,
title : "my title" ,
menu :
{
title : "my menu title" ,
label : "my label"
}
}
var evaluator:PropertyEvaluator = new PropertyEvaluator( obj ) ;
// valid expressions
trace( evaluator.eval( "message" ) ) ; // hello world
trace( evaluator.eval( "title" ) ) ; // my title
trace( evaluator.eval( "menu.title" ) ) ; // my menu title
trace( evaluator.eval( "menu.label" ) ) ; // my label
// invalid expressions
trace( evaluator.eval( "" ) ) ; // null
trace( evaluator.eval( "unknow" ) ) ; // null
trace( evaluator.eval( "menu.unknow" ) ) ; // null
// change the "undefineable" value returns in the eval() method when the evaluation failed.
evaluator.undefineable = "empty" ;
trace( evaluator.eval( "unknow" ) ) ; // empty ;
evaluator.undefineable = undefined ;
trace( evaluator.eval( "unknow" ) ) ; // undefined ;
// activate the throwError mode.
evaluator.throwError = true ;
try
{
evaluator.eval( "test" ) ;
}
catch( e:Error )
{
trace( e ) ; // EvalError: [object PropertyEvaluator] eval failed with the expression : test
}
| Property | Defined By | ||
|---|---|---|---|
| separator : String = .
The separator of the expression evaluator. | PropertyEvaluator | ||
| target : *
The target reference use in the evaluator. | PropertyEvaluator | ||
| throwError : Boolean
Indicates if the eval() method throws errors or return null when an error is throwing. | PropertyEvaluator | ||
| undefineable : * = null
This attributs defines the value returns from the eval() method if the expression can't be evaluate. | PropertyEvaluator | ||
| Method | Defined By | ||
|---|---|---|---|
PropertyEvaluator(target:* = null)
Creates a new PropertyEvaluator instance. | PropertyEvaluator | ||
eval(o:*):*
Evaluates the specified object. | PropertyEvaluator | ||
| separator | property |
public var separator:String = .The separator of the expression evaluator.
| target | property |
target:*The target reference use in the evaluator.
public function get target():* public function set target(value:any):void| throwError | property |
public var throwError:BooleanIndicates if the eval() method throws errors or return null when an error is throwing.
| undefineable | property |
public var undefineable:* = nullThis attributs defines the value returns from the eval() method if the expression can't be evaluate.
| PropertyEvaluator | () | Constructor |
public function PropertyEvaluator(target:* = null)Creates a new PropertyEvaluator instance.
Parameterstarget:* (default = null) — the target object use in the evaluator.
|
| eval | () | method |
public function eval(o:*):*Evaluates the specified object.
Parameters
o:* |
* |