Interface for classes that can manager Formatters
Methods
addFormatters(formatterMap)
Adds formatters (any object that has .format(string) and returns a string)
Parameters:
Name | Type | Description |
---|---|---|
formatterMap |
Object.<string, Formatter> | Map of formatters where the key is the id of the formatter (what will match in the { }) and the value is the Formatter object that implements .format(value) and returns a string |
format(string, valuesMap) → {String}
Formats everything in the passed in string.
This does so by looking for any {id} in the string, where id is some text, and matching
the id to an id the formatterMap map and valuesMap.
The formatter found by the id is called using the value found in the valuesMap
Parameters:
Name | Type | Description |
---|---|---|
string |
String | The string to format that contatins N number of {someString} |
valuesMap |
Object.<string, Object> | The map that contains values where the key is equal to someString |
Returns:
A new string with all the values formatted and replaced
- Type
- String
getFormatter(formatterId) → {Formatter}
Returns the formatter stored under the formatterId
Parameters:
Name | Type | Description |
---|---|---|
formatterId |
String | The Id of the formatter to return |
Returns:
The formatter, null if not found;
- Type
- Formatter