Class: ExpressionFormatter

system.formatters. ExpressionFormatter


new ExpressionFormatter()

This object register formattable expression and format a String with all expressions register in this internal dictionnary.

Implements:
Example
var ExpressionFormatter = system.formatters.ExpressionFormatter ;

var formatter = new ExpressionFormatter() ;

formatter.set( "root"      , "c:"                     ) ;
formatter.set( "system"    , "{root}/project/system"  ) ;
formatter.set( "data.maps" , "{system}/data/maps"     ) ;
formatter.set( "map"       , "{data.maps}/HashMap.as" ) ;

source = "the root : {root} - the class : {map}" ;
// the root : c: - the class : c:/project/system/data/maps/HashMap.as

trace( formatter.length ) ;
trace( formatter.format( source ) ) ;

trace( "----" ) ;

formatter.clear() ;

formatter.set( "root"      , "c:"                     ) ;
formatter.set( "system"    , "%root%/project/system" ) ;
formatter.set( "data.maps" , "%system%/data/maps" ) ;
formatter.set( "HashMap"   , "%data.maps%/HashMap.as" ) ;

formatter.beginSeparator = "%" ;
formatter.endSeparator   = "%" ;

source = "the root : %root% - the class : %HashMap%" ;

trace( formatter.format( source ) ) ;
// the root : c: - the class : c:/project/system/data/maps/HashMap.as

Members


<static, constant> MAX_RECURSION :number

The limit of the recursions in the formatter (200).

Type:
  • number

beginSeparator

The begin separator of the expression to format (default "{").


endSeparator

The end separator of the expression to format (default "}" ).


expressions

The expressions reference


<readonly> length

Indicates the size of the expression dictionary.

Methods


clear()

Clear the expression formatter dictionary.


format(value)

Formats the specified value.

Parameters:
Name Type Description
value string

The string expression to format.

Returns:

the string representation of the formatted value.


set(key, value)

Sets a new expression in the formatter. If the expression already exist, the value in the collector is replaced.

Parameters:
Name Type Description
key string

The key of the element to register.

value string

The value of the element to register.

Returns:

true if the value is register.

Type
boolean

toString()

Returns the String representation of the object.

Returns:

the String representation of the object.