StringFormatter
| Kind of class: | class |
|---|---|
| Inherits from: | none |
| Author: | Jason Williams |
| Classpath: | mx.utils.StringFormatter |
| File last modified: | Tuesday, 18 December 2007, 15:44:38 |
The formatting class provides a mechanism for displaying and saving data in the specified format. The constructor
accepts the format and an array of tokens and uses these values to create the data structures to support the formatting
during data retrieval and saving.
accepts the format and an array of tokens and uses these values to create the data structures to support the formatting
during data retrieval and saving.
Summary
Constructor
- StringFormatter (format, tokens, extractTokenFunc, infuseTokenFunc)
Instance properties
Instance methods
- extractValue (formattedData, result)
- Extracts a value from the formatted data specified and stores it in the result value specified.
- formatValue (value)
- Returns the specified value formatted with the current format settings.
- getFormat
- setFormat (format, tokens)
- Sets the new formatting to the specified value.
Constructor
StringFormatter
function StringFormatter (
format,
tokens,
extractTokenFunc,
infuseTokenFunc)
Instance properties
__extractToken
__extractToken
(read)
__format
__format:Function
(read)
__infuseToken
__infuseToken
(read)
__tokenInfo
__tokenInfo
(read)
Instance methods
extractValue
function extractValue (
formattedData,
result)
Extracts a value from the formatted data specified and stores it in the result value specified. The formatted data
specified is treated as a string, this method uses the current format and tokens specified to read through the given
data to derive the result. The calculation of result is delegated to the infuseTokenFunc currently specified. This
method is called with the current token data and the value specified here in result, it is up to the infuseTokenFunc
to "infuse" the data passed to it into the result.
specified is treated as a string, this method uses the current format and tokens specified to read through the given
data to derive the result. The calculation of result is delegated to the infuseTokenFunc currently specified. This
method is called with the current token data and the value specified here in result, it is up to the infuseTokenFunc
to "infuse" the data passed to it into the result.
Parameters:
formattedData:
string containing the data to convert or extract and infuse into result
result :
reference to the data that will be extracted from the formattedData specified.@access private
Author:
- Jason Williams
formatValue
function formatValue (
value)
Returns the specified value formatted with the current format settings. The specified value is not interpreted
by this method, instead the current readTokenFunc is called with the value given here and the current token being
processed. The value returned from that method will be inserted into the format and returned.
by this method, instead the current readTokenFunc is called with the value given here and the current token being
processed. The value returned from that method will be inserted into the format and returned.
Parameters:
value:
contains the value to apply formatting to
Returns:
- string containing the specified value formatted using the current format settings@access private
Author:
- Jason Williams
getFormat
function getFormat (
)
Returns this formatter's current format string.
Returns:
- string containing the current format string.@access private
Author:
- Jason Williams
setFormat
function setFormat (
format,
tokens)
Sets the new formatting to the specified value.
Parameters:
format:
string containing the desired format
tokens:
comma delimited string containing the character tokens within the specified format string that
will be replaced during data formatting operations.
will be replaced during data formatting operations.
Example:
- Sets the formatting for a date to display two digits for the month, two for the day, and four for the year.
myFormatter.setFormat( "MM/DD/YYYY", "M, Y, D");@access private
Author:
- Jason Williams