Packagesystem.evaluators
Classpublic class PropertyEvaluator
InheritancePropertyEvaluator Inheritance Object
Implements Evaluable
Subclasses ConfigEvaluator, LocaleEvaluator

Evaluates a type string expression and return the property value who corresponding in the target object specified in this evaluator.

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
     }
     



Public Properties
 PropertyDefined 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
Public Methods
 MethodDefined By
  
PropertyEvaluator(target:* = null)
Creates a new PropertyEvaluator instance.
PropertyEvaluator
  
eval(o:*):*
Evaluates the specified object.
PropertyEvaluator
Property Detail
separatorproperty
public var separator:String = .

The separator of the expression evaluator.

targetproperty 
target:*

The target reference use in the evaluator.


Implementation
    public function get target():*
    public function set target(value:any):void
throwErrorproperty 
public var throwError:Boolean

Indicates if the eval() method throws errors or return null when an error is throwing.

undefineableproperty 
public var undefineable:* = null

This attributs defines the value returns from the eval() method if the expression can't be evaluate.

Constructor Detail
PropertyEvaluator()Constructor
public function PropertyEvaluator(target:* = null)

Creates a new PropertyEvaluator instance.

Parameters
target:* (default = null) — the target object use in the evaluator.
Method Detail
eval()method
public function eval(o:*):*

Evaluates the specified object.

Parameters

o:*

Returns
*