Package org.eclnt.util.valuemgmt
Class ValueManager
java.lang.Object
org.eclnt.util.valuemgmt.ValueManager
Utility functions around management of values.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
static interface
Some information for the value management is required "from outside".static class
static class
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
approveFileName
(String name) static String
static int
calculateScaledSize
(int pixelSize) Calculates a pixel value into a scaled pixel value.static boolean
static boolean
checkIfFileNamesAreEqual
(String s1, String s2) static boolean
checkIfFormatIsBoolean
(String format) static boolean
checkIfFormatIsDate
(String format) static boolean
checkIfFormatIsNumeric
(String format) static boolean
checkIfObjectsAreEqual
(Object o1, Object o2) static boolean
static boolean
checkIfSizeIsHintOnly
(String value) For some components sizes can be passed as minimum hint only.static boolean
checkIfStringContainsSearchString
(String s, String searchString) static boolean
checkIfStringContainsTokenizedSearchString
(String s, String searchString) static boolean
checkIfStringMatchesAsteriskExpression
(String value, String asterixExpression) static boolean
checkIfStringMatchesAsteriskExpression
(String value, String asterixExpression, boolean ignoreCase) static boolean
checkIfStringMatchesRegularExpression
(String value, String regularExpression) static boolean
checkIfStringMatchesSearchStringAND
(String s, String searchString) static boolean
checkIfStringMatchesSearchStringOR
(String s, String searchString) static boolean
checkIfStringsAreEqual
(String s1, String s2) static boolean
checkIfStringsAreEqual
(String s1, String s2, boolean ignoreSlashR) static boolean
checkIfXMLIsValid
(String m_content) static String
concatenateStrings
(List<String> items) Memory-optimized concatenation of strings.static String
convertFileNameToCanonical
(String fileName, boolean isDirectory) static char
convertHexCodeToChar
(String hexcode) static String
convertObject2ClientDisplayString
(Object value, String format, String formatmask, String timezone, boolean convertHTML, boolean export) Similar to methodconvertObject2DisplayString(Object, String, String, String, boolean, boolean)
but now using the client side Locale, so that the formatting follows the client side formatting.static String
convertObject2DisplayString
(Object value, String format, String formatmask, String timezone, boolean convertHTML) static String
convertObject2DisplayString
(Object value, String format, String formatmask, String timezone, boolean convertHTML, boolean export) Converts value object into string following formatting rules.static String
convertObject2DisplayString
(Object value, String format, String formatmask, String timezone, Locale l, boolean convertHTML, boolean export) Converts value object into string following formatting rules.static String
Converts object into string that can be transferred to the client.static Object
convertStringIntoEnum
(String attrValue, Class attrClass) static Object
convertStringIntoEnum
(String attrValue, Class attrClass, boolean withError) static String
Converts a string into a file name (no path consideration, only the last "end-file-name") and removes all characters that are not compatible with file system names (e.g. "/"...).static String
convertStringIntoFileName
(String name, boolean lowerCase) Extended version ofconvertStringIntoFileName(String)
, with explicit definition if to convert to lowercase or not.static String
Converts a string into a file path and removes all characters that are not compatible with file system names.static String
convertStringIntoFilePath
(String name, boolean lowerCase) Extended version ofconvertStringIntoFilePath(String)
, with explicit definition if to convert to lowercase or not.static Object
convertStringIntoObject
(String attrValue, Class attrClass) static Source
static String
createEmptyString
(int numberOfCharacters) static String
createHotKeyString
(ValueManager.HotKeyInfo hotKeyInfo) static int
decodeAlign
(String value) Decodes string "left", "right", "center", "leading", "trailing" into corresponding Swing integer.static boolean
decodeBoolean
(String value, boolean nullValue) static Color
decodeColor
(String colorCode) static Color
decodeColor
(String colorCode, boolean withError) static Color
decodeColor
(String colorCode, String nullValue) decodeComplexValue
(String value) decodeComplexValue
(String value, boolean withTrimming) static List<ValueManager.NameValue>
decodeComplexValueIntoList
(String value) static String[]
Decode complex comma separated value string.static String[]
Decode complex comma separated value string.static String[]
decodeCSVOneLine
(String value) decodeCSVOneLineToList
(String value) decodeCSVToList
(String value) decodeCSVToList
(String value, String nullString) static double
decodeDouble
(String value, double nullValue) static float
decodeFloat
(String value, float nullValue) static Font
decodeFont
(String value) static String
static byte
decodeHexChars
(char c16, char c1) static byte[]
static byte[]
decodeHexString
(String s, boolean withError) static ValueManager.HotKeyInfo
decodeHotKey
(String value) static ValueManager.ImageData
decodeImageName
(String imageName, boolean isLeftToRight) An image name may contain more information than the "URL" to the image:
"&mirrorrtl" ==> image will be mirrorred in case of right to left display
"&noscale" ==> image will NOT be scaled when the user increases the size factor of the screenstatic int
static int
decodeIntWithRounding
(String value, int nullValue) Same asdecodeInt(String, int)
but also checks if the value that is passed is a double value.static long
decodeLong
(String value, long nullValue) static long
decodeLongWithRounding
(String value, long nullValue) Same asdecodeLong(String, long)
but also checks if the value that is passed is a double value.static String
decodeMethodName
(String value) static String[]
decodeMethodParams
(String value) static int
decodeMinSize
(String value) A size value may contain a minimum size.static Padding
decodePadding
(String value) static String
decodePropertyName
(String methodName) Converts a getter method starting with "get" or "is" into a property name.static Rectangle
decodeRectangle
(String value, Rectangle nullValue) static int
decodeSize
(String value) static int
decodeSize
(String value, int nullValue) static int[]
decodeStraighIntCSV
(String value) Deprecated.static int[]
decodeStraighSizeCSV
(String value) Deprecated.static String[]
decodeStraightCSV
(String value) Same functions asdecodeCSV(String)
.static int[]
decodeStraightIntCSV
(String value) Decode semicolon separated strings of integer values.static int[]
decodeStraightSizeCSV
(String value) Decode semicolon separated strings of integer values.decodeStringListXML
(String s, boolean withError) static TextSelectionInfo
static int
decodeValign
(String value) static String
encodeAutocompleteIdText
(String id, String text) static String
encodeColor
(Color c) static String
encodeComplexValue
(List<ValueManager.NameValue> nameValueList) Encodes a complex value string of the format: "name:value;name:value;name:value"static String
encodeComplexValue
(List<ValueManager.NameValue> nameValueList, boolean ignoreNullValues) Encodes a complex value string of the format: "name:value;name:value;name:value"static String
encodeComplexValue
(Map<String, String> values) Encodes a complex value string of the format: "name:value;name:value;name:value"static String
encodeComplexValue
(Map<String, String> values, boolean ignoreNullValues) Encodes a complex value string of the format: "name:value;name:value;name:value"static String
Best way to encode comma separated strings.static String
Same asencodeCSV(String[])
, just with different way of passing strings.static String
Encoding of CSV, null-values are transferred into a defined string that is passed via parameter nullString.static String
encodeCSVOneLine
(String[] values) static String
encodeCSVWithQuotes
(List<String> values) Encodes list of values into CSV string, each string is embedded into quotes.static String
encodeCSVWithQuotes
(List<String> values, String delimiter) Encodes list of values into CSV string, each string is embedded into quotes.static String
encodeHexString
(byte[] bytes) static String
static String
static String
encodeIntoValidClassLoaderPath
(String s, boolean isDirectory) static String
encodeIntoValidFileName
(String s, boolean isDirectory) static String
encodeIntoValidStreamStorePath
(String s, boolean isDirectory) static String
static String
encodeIntoValidWebResourcePath
(String s, boolean isDirectory) static String
static String
static String
encodeMethod
(String methodName, String[] params) Encodes a method call strings, formed in the way: method(param1,param2).static String
encodeMethodParams
(List<String> params) Encode the method parameters as comma separated string with converting contained "," to "\x2C".static String
encodeMethodParamsArray
(String[] params) Encode the method parameters as comma separated string with converting contained "," to "\x2C".static String
encodeRectangle
(Rectangle value) static String
encodeRectangle
(Rectangle value, boolean scaleToLoxels) static String
encodeSize
(int value) static String
encodeStraightIntCSV
(int[] values) Transfer array of integer values into semicolon separated list of integer values.static String
encodeStraightSizeCSV
(int[] values) Transfer array of integer values into semicolon separated list of integer values.static String
static String
static String
encodeURLPart
(String urlPart) static String
static Format
findFormatter
(Object value, String format, String formatmask, String timezone, String language, String country) static Calendar
getCalendar
(String timezone) Get the default calendar.static Font
static Font
getLinesOfText
(String text) static int
getNumberOfDecimals
(String formatmask) static Class
getPreferredClassForFieldFormat
(String format, String timezone) static Class
getPreferredClassForFieldFormat
(String format, String timezone, boolean returnNullIfUnknown) static Set<ISimpleDataTypeExtension>
static ISimpleDataTypeExtension
static String
static void
Initialization is only required when working with fonts.static void
static void
initializeInfoProvider
(ValueManager.IValueManagerInfoProvider infoProvider) static boolean
static String
removeAllHtmlTags
(String html) static String
static String
static String
static String
static String
static String
static String
Removes the XML declaration which may be the start of an XML document.static String
replaceSystemProperties
(String s, boolean encodeToXml) Replaces place holders for system and environment variables in the text by corresponding values.static BigDecimal
rightScale
(BigDecimal value, int numberOfFractionDigits) Converts a big decimal according to formatmask.static String
rightSizeLineBreaks
(String text) Ensure that all carriage returns are "\r\n" definitions.static String[]
Internal method for splitting one string into its contained parts, separated by a separator.static String[]
tokenizeStringWithQuotes
(String inputs, char separator) Internal method for splitting one string into its contained parts, separated by a separator.static String
static String
static String
static String
static String
truncateString
(String s, int limit)
-
Field Details
-
CHAR_SEMI
- See Also:
-
CHAR_COMMA
- See Also:
-
CHARX_RETURN
- See Also:
-
CHARX_SEMI
- See Also:
-
CHARX_COMMA
- See Also:
-
CHARX_BRACKETOPEN
- See Also:
-
CHARX_BRACKETCLOSE
- See Also:
-
TIMEZONE_UTC
-
CALENDAR_UTC
-
CHARSET_UTF8
-
-
Constructor Details
-
ValueManager
public ValueManager()
-
-
Method Details
-
initializeInfoProvider
-
initializeAddSimpleDataTypeExtension
-
getSimpleDataTypeExtensions
-
getSimpleDataTypExtensionForClass
-
checkIfdAsAutocompleteIdText
-
encodeAutocompleteIdText
-
decodeStringListXML
-
encodeStringListXML
-
decodeRectangle
-
encodeRectangle
-
encodeRectangle
-
decodeHotKey
-
createHotKeyString
- Returns:
- Readable String for the hot key that can be appended to an existing text. Example: " (ctrl-alt-F1)".
-
decodeImageName
An image name may contain more information than the "URL" to the image:
"&mirrorrtl" ==> image will be mirrorred in case of right to left display
"&noscale" ==> image will NOT be scaled when the user increases the size factor of the screen -
decodeAlign
Decodes string "left", "right", "center", "leading", "trailing" into corresponding Swing integer. -
decodeValign
-
decodeCSV
Decode complex comma separated value string. Each value may internally hold ";" strings, which are represented as "\x3B". -
decodeCSVToList
-
decodeCSVOneLine
-
decodeCSVOneLineToList
-
decodeCSV
Decode complex comma separated value string. A certain string is interpreted as null-string. -
decodeCSVToList
-
decodeStraightCSV
Same functions asdecodeCSV(String)
. There is no separation between "straigh" and "normal" CSV value anymore.- Returns:
-
decodeStraightIntCSV
Decode semicolon separated strings of integer values. -
decodeStraighIntCSV
Deprecated. -
decodeStraightSizeCSV
Decode semicolon separated strings of integer values. -
decodeStraighSizeCSV
Deprecated. -
encodeCSV
Best way to encode comma separated strings. Passing an array of strings. The logic of the method automatically transfers contained characters into a "\x3B" representations. -
encodeCSVOneLine
-
encodeCSVWithQuotes
Encodes list of values into CSV string, each string is embedded into quotes. By default a semicolon is used as separator. -
encodeCSVWithQuotes
Encodes list of values into CSV string, each string is embedded into quotes. -
encodeCSV
Same asencodeCSV(String[])
, just with different way of passing strings. -
encodeCSV
Encoding of CSV, null-values are transferred into a defined string that is passed via parameter nullString. -
encodeStraightIntCSV
Transfer array of integer values into semicolon separated list of integer values. -
encodeStraightSizeCSV
Transfer array of integer values into semicolon separated list of integer values. -
decodeBoolean
-
encodeColor
-
decodeColor
- Parameters:
colorCode
- Color as "#RRGGBB" value.- Returns:
- Color as awt-color. Null in case of error.
-
decodeColor
-
decodeColor
- Parameters:
colorCode
- Color as "#RRGGBB" value.- Returns:
- Color as awt-color. Null in case of error.
-
decodeSize
- Parameters:
value
- Either pixel value "100" or percentage value "50%" or percentage definition with minimum "50%;100"- Returns:
- Integer representation: "100" or "-50".
-
decodeMinSize
A size value may contain a minimum size. This minimum size must be a pixel value.- Returns:
- pixel size of minimum size; -1 if nothing is defined
-
encodeSize
-
calculateScaledSize
public static int calculateScaledSize(int pixelSize) Calculates a pixel value into a scaled pixel value. -
decodeSize
-
checkIfSizeIsHintOnly
For some components sizes can be passed as minimum hint only. E.g. button has a size of "100" but if the text inside exceeds the button then the button will not be cut. In this case the size value is passed with "+" at the end. -
decodeComplexValue
- Parameters:
value
- String in the format "name=value;name=value;name=value"- Returns:
- Map that represented the value, key=name, value=value
-
decodeComplexValue
-
decodeComplexValueIntoList
- Parameters:
value
- String in the format "name=value;name=value;name=value"- Returns:
- List of contained name/value pairs. Important: the sequence of the name/value pairs is the same as in the value passed as parameter.
-
encodeComplexValue
Encodes a complex value string of the format: "name:value;name:value;name:value" -
encodeComplexValue
public static String encodeComplexValue(List<ValueManager.NameValue> nameValueList, boolean ignoreNullValues) Encodes a complex value string of the format: "name:value;name:value;name:value" -
encodeComplexValue
Encodes a complex value string of the format: "name:value;name:value;name:value" -
encodeComplexValue
Encodes a complex value string of the format: "name:value;name:value;name:value" -
initialize
public static void initialize()Initialization is only required when working with fonts. -
getDefaultFont
-
getDefaultScaledFont
-
decodeFont
- Parameters:
value
-- Returns:
-
decodePadding
-
decodeInt
- Parameters:
value
- String value of integer.nullValue
- Default value that is returned either if the value-parameter is null, or if any error occurs when decoding the integer value.- Returns:
-
decodeIntWithRounding
Same asdecodeInt(String, int)
but also checks if the value that is passed is a double value. If so then it is rounded to int. -
decodeFloat
-
decodeDouble
-
decodeLong
-
decodeLongWithRounding
Same asdecodeLong(String, long)
but also checks if the value that is passed is a double value. If so then it is rounded to int. -
decodeMethodParams
- Parameters:
value
- String value representing a method call e.g. onSave(firstName,lastName).- Returns:
- Array of parameters e.g. [firstName,lastName].
-
encodeMethod
Encodes a method call strings, formed in the way: method(param1,param2). If parameters contain "," on their owns these are converted to "\x2C" as part of the encoding process. -
encodeMethodParams
Encode the method parameters as comma separated string with converting contained "," to "\x2C". -
encodeMethodParamsArray
Encode the method parameters as comma separated string with converting contained "," to "\x2C". -
tokenize
Internal method for splitting one string into its contained parts, separated by a separator. -
tokenizeStringWithQuotes
Internal method for splitting one string into its contained parts, separated by a separator. The string may in adddition contain quotes which are respected -
decodeMethodName
- Parameters:
value
- String value representing a method call e.g. onSave(firstName,lastName).- Returns:
- Name of method, in the example: "onSave"
-
escapeXMLString
-
encodeIntoValidXMLString
-
encodeIntoEscapedString
-
encodeIntoValidXMLValueString
-
encodeIntoEscapedValueString
-
decodeFromXML
-
encodeIntoValidFileName
-
encodeIntoValidStreamStorePath
-
encodeIntoValidURL
-
encodeIntoValidWebResourcePath
-
encodeIntoValidClassLoaderPath
-
getStackstraceString
-
decodeHexChars
public static byte decodeHexChars(char c16, char c1) -
decodeHexString
-
decodeHexString
-
encodeHexString
-
getCalendar
Get the default calendar. The timezone is derived from the static member that is set by#setTimezone(String)
. -
decodePropertyName
Converts a getter method starting with "get" or "is" into a property name. Otherwise returns null. -
checkIfObjectsAreEqual
-
checkIfStringContainsTokenizedSearchString
-
checkIfStringContainsSearchString
-
checkIfFileNamesAreEqual
-
checkIfStringsAreEqual
-
checkIfStringsAreEqual
-
isEmpty
-
checkIfStringMatchesRegularExpression
-
checkIfStringMatchesAsteriskExpression
-
checkIfStringMatchesAsteriskExpression
-
checkIfStringMatchesSearchStringAND
- Parameters:
s
- String to be investigated.searchString
- space-separated string with search words- Returns:
- true if all of the searched words is contained in s
-
checkIfStringMatchesSearchStringOR
- Parameters:
s
- String to be investigated.searchString
- space-separated string with search words- Returns:
- true if one of the searched words is contained in s
-
checkIfSimpleDataType
-
convertStringIntoObject
-
convertStringIntoEnum
-
convertStringIntoEnum
-
convertObject2DisplayString
-
convertObject2DisplayString
public static String convertObject2DisplayString(Object value, String format, String formatmask, String timezone, boolean convertHTML, boolean export) Converts value object into string following formatting rules.- Parameters:
export
- During PDF/Excel export some characters are used in a different way as during export for screen purposes.
-
convertObject2ClientDisplayString
public static String convertObject2ClientDisplayString(Object value, String format, String formatmask, String timezone, boolean convertHTML, boolean export) Similar to methodconvertObject2DisplayString(Object, String, String, String, boolean, boolean)
but now using the client side Locale, so that the formatting follows the client side formatting. This is important when e.g converting server side seach values against their client representation. -
convertObject2DisplayString
public static String convertObject2DisplayString(Object value, String format, String formatmask, String timezone, Locale l, boolean convertHTML, boolean export) Converts value object into string following formatting rules. Extended version ofconvertObject2DisplayString(Object, String, String, String, boolean, boolean)
with possibility to pass Locale. -
convertObject2ValueString
Converts object into string that can be transferred to the client. -
getPreferredClassForFieldFormat
-
getPreferredClassForFieldFormat
-
rightScale
Converts a big decimal according to formatmask. -
decodeTextSelectionInfo
-
encodeTextSelectionInfo
-
truncateString
-
concatenateStrings
Memory-optimized concatenation of strings. -
removeAllHtmlTagsIfHtmlString
-
removeAllHtmlTags
-
removeDoubleSpacesAndTrim
-
toLowerCaseId
-
toUpperCaseId
-
toLowerCaseText
-
toUpperCaseText
-
findFormatter
-
getNumberOfDecimals
-
checkIfFormatIsNumeric
-
checkIfFormatIsDate
-
checkIfFormatIsBoolean
-
convertHexCodeToChar
-
checkIfXMLIsValid
-
encodeURLPart
-
rightSizeLineBreaks
Ensure that all carriage returns are "\r\n" definitions. -
approveFileName
-
convertFileNameToCanonical
-
replaceSystemProperties
Replaces place holders for system and environment variables in the text by corresponding values.
The place holders are following the convention "${env.xxxxx}" for environment variables (which are resolved usingSystem.getenv(String)
) and "${sys.xxxxx}" for system variables (which are resolved usingSystem.getProperty(String)
.
There are some dedicated place holders in addition which are replaced:
"${webappName}" - this is the name of the current application. The name is derived from the application's context path. The context path is usually staring with "/" - which is cut. In case the context path is "/" then "root" is returned.- Parameters:
encodeToXml
- If set to true then the result is encode to proper XML values - so that the XML string will not be invalid (e.g. characters like " and ' are correctly managed.- Returns:
- String with replaced place holders. If a place holder cannot be resolved then the place holder is left untouched.
-
removeLeadingXMLDeclaration
Removes the XML declaration which may be the start of an XML document. This may be required if concatenating several XMLs into one XML. -
convertStringIntoXMLSource
-
getLinesOfText
-
buildTimeStamp
-
convertStringIntoFilePath
Converts a string into a file path and removes all characters that are not compatible with file system names. The characters are converted to lower case. -
convertStringIntoFilePath
Extended version ofconvertStringIntoFilePath(String)
, with explicit definition if to convert to lowercase or not. -
convertStringIntoFileName
Converts a string into a file name (no path consideration, only the last "end-file-name") and removes all characters that are not compatible with file system names (e.g. "/"...). The characters are converted to lower case. -
convertStringIntoFileName
Extended version ofconvertStringIntoFileName(String)
, with explicit definition if to convert to lowercase or not. -
removeDirectoryPathAndExtensionFromFileName
-
removeExtensionFromFileName
-
removeDirectoryPathFromFileName
-
removeFileNameFromDirectoryPath
-
createEmptyString
-