Package org.eclnt.util.valuemgmt
Class ValueManager
java.lang.Object
org.eclnt.util.valuemgmt.ValueManager
Utility functions around management of values.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic interfaceSome information for the value management is required "from outside".static classstatic class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringapproveFileName(String name) static Stringstatic intcalculateScaledSize(int pixelSize) Calculates a pixel value into a scaled pixel value.static booleanstatic booleanstatic booleancheckIfFileNamesAreEqual(String s1, String s2) static booleancheckIfFormatIsBoolean(String format) static booleancheckIfFormatIsDate(String format) static booleancheckIfFormatIsNumeric(String format) static booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleanstatic booleancheckIfObjectsAreEqual(Object o1, Object o2) static booleanstatic booleancheckIfSizeIsHintOnly(String value) For some components sizes can be passed as minimum hint only.static booleancheckIfStringContainsSearchString(String s, String searchString) static booleancheckIfStringContainsTokenizedSearchString(String s, String searchString) static booleancheckIfStringMatchesAsteriskExpression(String value, String asterixExpression) static booleancheckIfStringMatchesAsteriskExpression(String value, String asterixExpression, boolean ignoreCase) static booleancheckIfStringMatchesRegularExpression(String value, String regularExpression) static booleancheckIfStringMatchesSearchStringAND(String s, String searchString) static booleancheckIfStringMatchesSearchStringAND(String s, String searchString, boolean caseSensitive) static booleancheckIfStringMatchesSearchStringOR(String s, String searchString) static booleancheckIfStringsAreEqual(String s1, String s2) static booleancheckIfStringsAreEqual(String s1, String s2, boolean ignoreSlashR) static booleancheckIfXMLIsValid(String m_content) static StringconcatenateStrings(List<String> items) Memory-optimized concatenation of strings.static StringconvertFileNameToCanonical(String fileName, boolean isDirectory) static charconvertHexCodeToChar(String hexcode) static StringconvertObject2ClientDisplayString(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 Stringstatic StringconvertObject2DisplayString(Object value, String format, String formatmask, String timezone, boolean convertHTML) static StringconvertObject2DisplayString(Object value, String format, String formatmask, String timezone, boolean convertHTML, boolean export) Converts value object into string following formatting rules.static StringconvertObject2DisplayString(Object value, String format, String formatmask, String timezone, Locale l, boolean convertHTML, boolean export) Converts value object into string following formatting rules.static StringConverts object into string that can be transferred to the client.static ObjectconvertStringIntoEnum(String attrValue, Class attrClass) static ObjectconvertStringIntoEnum(String attrValue, Class attrClass, boolean withError) static StringConverts 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 StringconvertStringIntoFileName(String name, boolean lowerCase) Extended version ofconvertStringIntoFileName(String), with explicit definition if to convert to lowercase or not.static StringConverts a string into a file path and removes all characters that are not compatible with file system names.static StringconvertStringIntoFilePath(String name, boolean lowerCase) Extended version ofconvertStringIntoFilePath(String), with explicit definition if to convert to lowercase or not.static ObjectconvertStringIntoObject(String attrValue, Class attrClass) static Sourcestatic intcountOccurrancesInString(String s, char c) static StringcreateEmptyString(int numberOfCharacters) static StringcreateHotKeyString(ValueManager.HotKeyInfo hotKeyInfo) static intdecodeAlign(String value) Decodes string "left", "right", "center", "leading", "trailing" into corresponding Swing integer.static booleandecodeBoolean(String value, boolean nullValue) static ColordecodeColor(String colorCode) static ColordecodeColor(String colorCode, boolean withError) static ColordecodeColor(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 doubledecodeDouble(String value, double nullValue) static floatdecodeFloat(String value, float nullValue) static FontdecodeFont(String value) static Stringstatic bytedecodeHexChars(char c16, char c1) static byte[]static byte[]decodeHexString(String s, boolean withError) static ValueManager.HotKeyInfodecodeHotKey(String value) static ValueManager.ImageDatadecodeImageName(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 intstatic intdecodeIntWithRounding(String value, int nullValue) Same asdecodeInt(String, int)but also checks if the value that is passed is a double value.static longdecodeLong(String value, long nullValue) static longdecodeLongWithRounding(String value, long nullValue) Same asdecodeLong(String, long)but also checks if the value that is passed is a double value.static StringdecodeMethodName(String value) static String[]decodeMethodParams(String value) static intdecodeMinSize(String value) A size value may contain a minimum size.static PaddingdecodePadding(String value) static StringdecodePropertyName(String methodName) Converts a getter method starting with "get" or "is" into a property name.static RectangledecodeRectangle(String value, Rectangle nullValue) static intdecodeSize(String value) static intdecodeSize(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 TextSelectionInfostatic intdecodeValign(String value) static StringencodeAutocompleteIdText(String id, String text) static StringencodeColor(Color c) static StringencodeComplexValue(String... nameValues) Simplified version ofencodeComplexValue(Map)by directly passing a String-array.static StringencodeComplexValue(List<ValueManager.NameValue> nameValueList) Encodes a complex value string of the format: "name:value;name:value;name:value"static StringencodeComplexValue(List<ValueManager.NameValue> nameValueList, boolean ignoreNullValues) Encodes a complex value string of the format: "name:value;name:value;name:value"static StringencodeComplexValue(Map<String, ?> values) Encodes a complex value string of the format: "name:value;name:value;name:value"static StringencodeComplexValue(Map<String, ?> values, boolean ignoreNullValues) Encodes a complex value string of the format: "name:value;name:value;name:value"static StringBest way to encode comma separated strings.static StringSame asencodeCSV(String[]), just with different way of passing strings.static StringEncoding of CSV, null-values are transferred into a defined string that is passed via parameter nullString.static StringencodeCSVOneLine(String[] values) static StringencodeCSVWithQuotes(List<String> values) Encodes list of values into CSV string, each string is embedded into quotes.static StringencodeCSVWithQuotes(List<String> values, String delimiter) Encodes list of values into CSV string, each string is embedded into quotes.static StringencodeHexString(byte[] bytes) static Stringstatic Stringstatic StringencodeIntoValidClassLoaderPath(String s, boolean isDirectory) static Stringstatic Stringstatic StringencodeIntoValidFileName(String s, boolean isDirectory) static StringencodeIntoValidStreamStorePath(String s, boolean isDirectory) static Stringstatic StringencodeIntoValidWebResourcePath(String s, boolean isDirectory) static Stringstatic Stringstatic StringencodeMethod(String methodName, String[] params) Encodes a method call strings, formed in the way: method(param1,param2).static StringencodeMethodParams(List<String> params) Encode the method parameters as comma separated string with converting contained "," to "\x2C".static StringencodeMethodParamsArray(String[] params) Encode the method parameters as comma separated string with converting contained "," to "\x2C".static StringencodeRectangle(Rectangle value) static StringencodeRectangle(Rectangle value, boolean scaleToLoxels) static StringencodeSize(int value) static StringencodeStraightIntCSV(int[] values) Transfer array of integer values into semicolon separated list of integer values.static StringencodeStraightSizeCSV(int[] values) Transfer array of integer values into semicolon separated list of integer values.static Stringstatic Stringstatic StringencodeURLPart(String urlPart) static Stringstatic FormatfindFormatter(Object value, String format, String formatmask, String timezone, String language, String country) static CalendargetCalendar(String timezone) Get the default calendar.static Fontstatic FontgetLinesOfText(String text) static intgetNumberOfDecimals(String formatmask) static ClassgetPreferredClassForFieldFormat(String format, String timezone) static ClassgetPreferredClassForFieldFormat(String format, String timezone, boolean returnNullIfUnknown) static Set<ISimpleDataTypeExtension>static ISimpleDataTypeExtensionstatic Stringstatic voidInitialization is only required when working with fonts.static voidstatic voidinitializeInfoProvider(ValueManager.IValueManagerInfoProvider infoProvider) static booleanstatic StringremoveAllHtmlTags(String html) static Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic Stringstatic StringRemoves the XML declaration which may be the start of an XML document.static StringreplaceSystemProperties(String s, String context, boolean encodeToXml) Replaces place holders for system and environment variables in the text by corresponding values.static BigDecimalrightScale(BigDecimal value, int numberOfFractionDigits) Converts a big decimal according to formatmask.static StringrightSizeLineBreaks(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 Stringstatic Stringstatic Stringstatic Stringstatic StringtruncateString(String s, int limit) static StringtruncateStringAtBegin(String s, int limit) static StringupdateColor(String colorCodePM) static StringupdateColor(String colorCode, int factor)
-
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
-
updateColor
-
countOccurrancesInString
-
updateColor
-
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
Simplified version ofencodeComplexValue(Map)by directly passing a String-array. The array must be passed in the way: name1, value1, name2, value2, name3, value3, ... -
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
-
encodeIntoValidDirectoryName
-
encodeIntoValidFileName
-
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
-
checkIfStringMatchesSearchStringAND
-
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
-
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
-
truncateStringAtBegin
-
concatenateStrings
Memory-optimized concatenation of strings. -
removeAllHtmlTagsIfHtmlString
-
removeAllHtmlTags
-
removeDoubleSpacesAndTrim
-
toLowerCaseId
-
toUpperCaseId
-
toLowerCaseText
-
toUpperCaseText
-
findFormatter
-
getNumberOfDecimals
-
checkIfFormatIsNumeric
-
checkIfFormatIsNumericWithDecimals
-
checkIfFormatIsNumericNoDecimals
-
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
-
checkIfClassIsNumber
-
checkIfObjectIsNumber
-
checkIfObjectIsDate
-
checkIfObjectIsTime
-
checkIfObjectIsDateTime
-