Class FWFrameworkHelper
java.lang.Object
net.simplace.core.FWFrameworkHelper
Static helper methods of the framework, mainly for parameter maps: reading typed parameters, processing templates
and localizing form component values. Parameter tokens and expressions are replaced by
FWParameterResolver.- Author:
- Andreas Enders
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final charthe currency sign (ISO-8859-1 code 164) -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckEquals(Object aValueCalculated, Object aValueExpected, FWSimVariable.DATA_TYPE aDATA_TYPE) Compares a calculated with an expected value according to the data type; doubles (also in arrays) are compared with a tolerance of 0.00001.static StringcreateFormComponentLocaleBundleKey(FWObservable aObservable, String aFormComponentID, String aShortKey) Creates a locale bundle key for the specified short key.createMapFromCollection(Collection<T> tLoopList) static <T extends Number>
TgetNumberParameterFromMap(Map<String, Object> aParamMap, String aKey, Class<T> aNumberType, T aDefault) Getting parameter value from map as a number.static ObjectReturns a parameter value.getParametersMatchingRegex(Map<String, Object> aMap, String aRegexString) static StringReturns a parameter value as string, seegetParameterFromMap(Map, String, Object).static StringlocalizeFormComponentValue(FWObservable aObservable, String aFormComponentID, String aFormComponentValue) Localizes a form component value (e.g.static StringReplaces the tokens${name}of a template: names in the parameter map or starting with_viaFWParameterResolver.replace(Map, String, Object, boolean), all others by the column of the current result set row.static voidreplaceParamsInFile(FWObservable aObservable, File aFile) Replaces the parameters and evaluates the expressions within a text file; the file is overwritten.static StringtoStringForm(Collection<FWSimVariable<?>> aVariableList, String aSeparator) Lists variables as text, one linename separator valueper variable; dots in the names are replaced by the separator as well.transformMapToStringValue(Map<String, Object> aParameterMap)
-
Field Details
-
WEBEUROSIGN
public static final char WEBEUROSIGNthe currency sign (ISO-8859-1 code 164)- See Also:
-
-
Method Details
-
getParameterFromMap
public static Object getParameterFromMap(Map<String, Object> aParamMap, String aKey, Object aDefault) Returns a parameter value. String values have their parameter tokens replaced (seeFWParameterResolver.replace(Map, String, Object, boolean)).- Parameters:
aParamMap- the parameter mapaKey- the keyaDefault- value returned if the key isnullor has no value- Returns:
- the parameter value, or the default
-
getStringParameterFromMap
public static String getStringParameterFromMap(Map<String, Object> aParamMap, String aKey, Object aDefault) Returns a parameter value as string, seegetParameterFromMap(Map, String, Object).- Parameters:
aParamMap- the parameter mapaKey- the keyaDefault- value used if the parameter has no value- Returns:
- the value as string, or
nullif neither value nor default exist
-
getNumberParameterFromMap
public static <T extends Number> T getNumberParameterFromMap(Map<String, Object> aParamMap, String aKey, Class<T> aNumberType, T aDefault) Getting parameter value from map as a number.- Type Parameters:
T- the number type- Parameters:
aParamMap- map the parameter is taken fromaKey- key for the mapaNumberType- number type, the determined value is converted to (subclass ofNumber)aDefault- default value, which is returned if parameter not set or value can not be converted toaNumberType.- Returns:
- parameter value from map as a number
-
processTemplate
public static String processTemplate(String aTemplate, ResultSet aResultSet, Map<String, Object> aParameterMap) Replaces the tokens${name}of a template: names in the parameter map or starting with_viaFWParameterResolver.replace(Map, String, Object, boolean), all others by the column of the current result set row. Errors are logged.- Parameters:
aTemplate- the template textaResultSet- result set (current row) providing column values, may benullaParameterMap- the parameter map- Returns:
- the processed template (partially processed on errors)
-
transformMapToStringValue
-
getParametersMatchingRegex
-
replaceParamsInFile
Replaces the parameters and evaluates the expressions within a text file; the file is overwritten. Errors are logged.- Parameters:
aObservable- provides the parameter mapaFile- the text file
-
createMapFromCollection
- Type Parameters:
T- element type- Parameters:
tLoopList- the elements- Returns:
- a map (in element order) with the elements as keys and
nullvalues
-
createFormComponentLocaleBundleKey
public static String createFormComponentLocaleBundleKey(FWObservable aObservable, String aFormComponentID, String aShortKey) Creates a locale bundle key for the specified short key. Parameter wildcards in short key are replaced from parameter map. Spaces in short key are replaced by "_". If form component ID is specified, it is used as prefix for locale bundle key (besides standard prefix:.FormComponent). - Parameters:
aObservable- used to retrieve the parameter map to replace wildcards in short key (from parameter map)aFormComponentID- form component ID, which is used as prefix for localization key (can benullor empty)aShortKey- short key- Returns:
nullifaShortKeyisnull
-
localizeFormComponentValue
public static String localizeFormComponentValue(FWObservable aObservable, String aFormComponentID, String aFormComponentValue) Localizes a form component value (e.g. table cell value from database) by generating a locale bundle key from value as follows: Parameter wildcards in form component value are replaced from parameter map. Spaces in form component value are replaced by "_". If form component ID is specified, it is used as prefix for locale bundle key (besides standard prefix:.FormComponent). - Parameters:
aObservable- used to retrieve the parameter map to replace wildcards in short key (from parameter map)aFormComponentID- form component ID, which is used as prefix for localization key (can benullor empty)aFormComponentValue- value to determine a localization for- Returns:
- unchanged form component value, if no localization can be found
-
checkEquals
public static boolean checkEquals(Object aValueCalculated, Object aValueExpected, FWSimVariable.DATA_TYPE aDATA_TYPE) Compares a calculated with an expected value according to the data type; doubles (also in arrays) are compared with a tolerance of 0.00001.- Parameters:
aValueCalculated- the calculated valueaValueExpected- the expected value;nullmeans no checkaDATA_TYPE- the data type of both values- Returns:
trueif the values are equal or no value is expected
-
toStringForm
Lists variables as text, one linename separator valueper variable; dots in the names are replaced by the separator as well.- Parameters:
aVariableList- the variablesaSeparator- the separator- Returns:
- the lines, each ending with
\r\n; empty for an empty list
-