rialto.utils.Formatter


Name space rialto.utils.Formatter
FILE rialtoEngine\javascript\rialto\session.js
NAME rialto.utils.Formatter
INHERITS
VERSION 1.0
update
DESCRIPTION Data Formatter

There is 4 primitive types: number, date, boolean and hour.


CONSTRUCTOR


Name Type Description Default
pattern String Pattern to use. If not use the defaultPattern of the given type
maskPattern String maskPattern to use. If not use the pattern

Example:
          var formatter=new rialto.utils.Formatter({type:"date"});  
        

PUBLIC METHODS


Method Arguments list Return value Inherits To redefine
addType (STATIC) String type,Function f,Function p,Function v,String pattern void no no
setDefaultPattern (STATIC) String type,String pattern void no no
getDefaultPattern String type String no no
setPattern String pattern void no no
getPattern String no no
setMaskPattern String pattern void no no
getMaskPattern String no no
applyMask String value String no no
retrieveMask String value String no no
format Object data,boolean useMaskPattern String no no
parse String value,boolean useMaskPattern String no no
validate String value,boolean useMaskPattern boolean no no

addType (STATIC)

to add a new dataType
Parameters:
String type:type of data
Function f:format function
Function p:parse function
Function v:validate function
String pattern:default pattern
Example:
rialto.utils.Formatter.prototype.addType("type", function() {...},function(){...},function(){...},"pattern")

setDefaultPattern (STATIC)

to change the default pattern of a data type
Parameters:
String type:type of data
String pattern:pattern
Example:
rialto.utils.Formatter.prototype.setDefaultPattern("date", "MM-dd-yyyy")

getDefaultPattern

get the default pattern of a data type
Parameters:
String type:type of data

setPattern

set the pattern to use
Parameters:
String pattern:pattern to use

getPattern

return the current use pattern
Parameters:

setMaskPattern

set the pattern to use
Parameters:
String pattern:maskPattern to use

getMaskPattern

return the current maskpattern use
Parameters:

applyMask

return a value matching the maskPattern from a one matching the pattern use
Parameters:
String value:value to use

retrieveMask

return a value matching the pattern from a one matching the maskPattern use
Parameters:
String value:value to use

format

return a value from the data
Parameters:
Object data:data to format
boolean useMaskPattern:if true use the maskPattern else use the pattern

parse

return a data from the value
Parameters:
String value:value to parse to parse
boolean useMaskPattern:if true use the maskPattern else use the pattern

validate

return true if the data is valid
Parameters:
String value:value to parse to parse
boolean useMaskPattern:if true use the maskPattern else use the pattern