Class ValueManager

java.lang.Object
org.eclnt.util.valuemgmt.ValueManager

public class ValueManager extends Object
Utility functions around management of values.
  • Field Details

  • Constructor Details

    • ValueManager

      public ValueManager()
  • Method Details

    • initializeInfoProvider

      public static void initializeInfoProvider(ValueManager.IValueManagerInfoProvider infoProvider)
    • initializeAddSimpleDataTypeExtension

      public static void initializeAddSimpleDataTypeExtension(ISimpleDataTypeExtension extension)
    • getSimpleDataTypeExtensions

      public static Set<ISimpleDataTypeExtension> getSimpleDataTypeExtensions()
    • getSimpleDataTypExtensionForClass

      public static ISimpleDataTypeExtension getSimpleDataTypExtensionForClass(Class c)
    • checkIfdAsAutocompleteIdText

      public static boolean checkIfdAsAutocompleteIdText(String value)
    • encodeAutocompleteIdText

      public static String encodeAutocompleteIdText(String id, String text)
    • decodeStringListXML

      public static List<String> decodeStringListXML(String s, boolean withError)
    • encodeStringListXML

      public static String encodeStringListXML(List<String> l)
    • decodeRectangle

      public static Rectangle decodeRectangle(String value, Rectangle nullValue)
    • encodeRectangle

      public static String encodeRectangle(Rectangle value)
    • encodeRectangle

      public static String encodeRectangle(Rectangle value, boolean scaleToLoxels)
    • decodeHotKey

      public static ValueManager.HotKeyInfo decodeHotKey(String value)
    • createHotKeyString

      public static String createHotKeyString(ValueManager.HotKeyInfo hotKeyInfo)
      Returns:
      Readable String for the hot key that can be appended to an existing text. Example: " (ctrl-alt-F1)".
    • decodeImageName

      public 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 screen
    • decodeAlign

      public static int decodeAlign(String value)
      Decodes string "left", "right", "center", "leading", "trailing" into corresponding Swing integer.
    • decodeValign

      public static int decodeValign(String value)
    • decodeCSV

      public static String[] decodeCSV(String value)
      Decode complex comma separated value string. Each value may internally hold ";" strings, which are represented as "\x3B".
    • decodeCSVToList

      public static List<String> decodeCSVToList(String value)
    • decodeCSVOneLine

      public static String[] decodeCSVOneLine(String value)
    • decodeCSVOneLineToList

      public static List<String> decodeCSVOneLineToList(String value)
    • decodeCSV

      public static String[] decodeCSV(String value, String nullString)
      Decode complex comma separated value string. A certain string is interpreted as null-string.
    • decodeCSVToList

      public static List<String> decodeCSVToList(String value, String nullString)
    • decodeStraightCSV

      public static String[] decodeStraightCSV(String value)
      Same functions as decodeCSV(String). There is no separation between "straigh" and "normal" CSV value anymore.
      Returns:
    • decodeStraightIntCSV

      public static int[] decodeStraightIntCSV(String value)
      Decode semicolon separated strings of integer values.
    • decodeStraighIntCSV

      @Deprecated public static int[] decodeStraighIntCSV(String value)
      Deprecated.
    • decodeStraightSizeCSV

      public static int[] decodeStraightSizeCSV(String value)
      Decode semicolon separated strings of integer values.
    • decodeStraighSizeCSV

      @Deprecated public static int[] decodeStraighSizeCSV(String value)
      Deprecated.
    • encodeCSV

      public static String encodeCSV(String[] values)
      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

      public static String encodeCSVOneLine(String[] values)
    • encodeCSVWithQuotes

      public static String encodeCSVWithQuotes(List<String> values)
      Encodes list of values into CSV string, each string is embedded into quotes. By default a semicolon is used as separator.
    • encodeCSVWithQuotes

      public static String encodeCSVWithQuotes(List<String> values, String delimiter)
      Encodes list of values into CSV string, each string is embedded into quotes.
    • encodeCSV

      public static String encodeCSV(List<String> values)
      Same as encodeCSV(String[]), just with different way of passing strings.
    • encodeCSV

      public static String encodeCSV(List<String> values, String nullString)
      Encoding of CSV, null-values are transferred into a defined string that is passed via parameter nullString.
    • encodeStraightIntCSV

      public static String encodeStraightIntCSV(int[] values)
      Transfer array of integer values into semicolon separated list of integer values.
    • encodeStraightSizeCSV

      public static String encodeStraightSizeCSV(int[] values)
      Transfer array of integer values into semicolon separated list of integer values.
    • decodeBoolean

      public static boolean decodeBoolean(String value, boolean nullValue)
    • encodeColor

      public static String encodeColor(Color c)
    • decodeColor

      public static Color decodeColor(String colorCode)
      Parameters:
      colorCode - Color as "#RRGGBB" value.
      Returns:
      Color as awt-color. Null in case of error.
    • decodeColor

      public static Color decodeColor(String colorCode, boolean withError)
    • decodeColor

      public static Color decodeColor(String colorCode, String nullValue)
      Parameters:
      colorCode - Color as "#RRGGBB" value.
      Returns:
      Color as awt-color. Null in case of error.
    • decodeSize

      public static int decodeSize(String value)
      Parameters:
      value - Either pixel value "100" or percentage value "50%" or percentage definition with minimum "50%;100"
      Returns:
      Integer representation: "100" or "-50".
    • decodeMinSize

      public static int decodeMinSize(String value)
      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

      public static String encodeSize(int value)
    • calculateScaledSize

      public static int calculateScaledSize(int pixelSize)
      Calculates a pixel value into a scaled pixel value.
    • decodeSize

      public static int decodeSize(String value, int nullValue)
    • checkIfSizeIsHintOnly

      public static boolean checkIfSizeIsHintOnly(String value)
      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

      public static Map<String,String> decodeComplexValue(String value)
      Parameters:
      value - String in the format "name=value;name=value;name=value"
      Returns:
      Map that represented the value, key=name, value=value
    • decodeComplexValue

      public static Map<String,String> decodeComplexValue(String value, boolean withTrimming)
    • decodeComplexValueIntoList

      public static List<ValueManager.NameValue> decodeComplexValueIntoList(String value)
      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

      public static String encodeComplexValue(List<ValueManager.NameValue> nameValueList)
      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

      public static String encodeComplexValue(Map<String,String> values)
      Encodes a complex value string of the format: "name:value;name:value;name:value"
    • encodeComplexValue

      public static String encodeComplexValue(Map<String,String> values, boolean ignoreNullValues)
      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

      public static Font getDefaultFont()
    • getDefaultScaledFont

      public static Font getDefaultScaledFont()
    • decodeFont

      public static Font decodeFont(String value)
      Parameters:
      value -
      Returns:
    • decodePadding

      public static Padding decodePadding(String value)
    • decodeInt

      public static int decodeInt(String value, int nullValue)
      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

      public static int decodeIntWithRounding(String value, int nullValue)
      Same as decodeInt(String, int) but also checks if the value that is passed is a double value. If so then it is rounded to int.
    • decodeFloat

      public static float decodeFloat(String value, float nullValue)
    • decodeDouble

      public static double decodeDouble(String value, double nullValue)
    • decodeLong

      public static long decodeLong(String value, long nullValue)
    • decodeLongWithRounding

      public static long decodeLongWithRounding(String value, long nullValue)
      Same as decodeLong(String, long) but also checks if the value that is passed is a double value. If so then it is rounded to int.
    • decodeMethodParams

      public static String[] decodeMethodParams(String value)
      Parameters:
      value - String value representing a method call e.g. onSave(firstName,lastName).
      Returns:
      Array of parameters e.g. [firstName,lastName].
    • encodeMethod

      public static String encodeMethod(String methodName, String[] params)
      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

      public static String encodeMethodParams(List<String> params)
      Encode the method parameters as comma separated string with converting contained "," to "\x2C".
    • encodeMethodParamsArray

      public static String encodeMethodParamsArray(String[] params)
      Encode the method parameters as comma separated string with converting contained "," to "\x2C".
    • tokenize

      public static String[] tokenize(String inputs, String separator)
      Internal method for splitting one string into its contained parts, separated by a separator.
    • tokenizeStringWithQuotes

      public static String[] tokenizeStringWithQuotes(String inputs, char separator)
      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

      public static String decodeMethodName(String value)
      Parameters:
      value - String value representing a method call e.g. onSave(firstName,lastName).
      Returns:
      Name of method, in the example: "onSave"
    • escapeXMLString

      public static String escapeXMLString(String s)
    • encodeIntoValidXMLString

      public static String encodeIntoValidXMLString(String s)
    • encodeIntoEscapedString

      public static String encodeIntoEscapedString(String s)
    • encodeIntoValidXMLValueString

      public static String encodeIntoValidXMLValueString(String s)
    • encodeIntoEscapedValueString

      public static String encodeIntoEscapedValueString(String s)
    • decodeFromXML

      public static String decodeFromXML(String s)
    • encodeIntoValidFileName

      public static String encodeIntoValidFileName(String s, boolean isDirectory)
    • encodeIntoValidStreamStorePath

      public static String encodeIntoValidStreamStorePath(String s, boolean isDirectory)
    • encodeIntoValidURL

      public static String encodeIntoValidURL(String s)
    • encodeIntoValidWebResourcePath

      public static String encodeIntoValidWebResourcePath(String s, boolean isDirectory)
    • encodeIntoValidClassLoaderPath

      public static String encodeIntoValidClassLoaderPath(String s, boolean isDirectory)
    • getStackstraceString

      public static String getStackstraceString(Throwable t)
    • decodeHexChars

      public static byte decodeHexChars(char c16, char c1)
    • decodeHexString

      public static byte[] decodeHexString(String s)
    • decodeHexString

      public static byte[] decodeHexString(String s, boolean withError)
    • encodeHexString

      public static String encodeHexString(byte[] bytes)
    • getCalendar

      public static Calendar getCalendar(String timezone)
      Get the default calendar. The timezone is derived from the static member that is set by #setTimezone(String).
    • decodePropertyName

      public static String decodePropertyName(String methodName)
      Converts a getter method starting with "get" or "is" into a property name. Otherwise returns null.
    • checkIfObjectsAreEqual

      public static boolean checkIfObjectsAreEqual(Object o1, Object o2)
    • checkIfStringContainsTokenizedSearchString

      public static boolean checkIfStringContainsTokenizedSearchString(String s, String searchString)
    • checkIfStringContainsSearchString

      public static boolean checkIfStringContainsSearchString(String s, String searchString)
    • checkIfFileNamesAreEqual

      public static boolean checkIfFileNamesAreEqual(String s1, String s2)
    • checkIfStringsAreEqual

      public static boolean checkIfStringsAreEqual(String s1, String s2)
    • checkIfStringsAreEqual

      public static boolean checkIfStringsAreEqual(String s1, String s2, boolean ignoreSlashR)
    • isEmpty

      public static boolean isEmpty(String s)
    • checkIfStringMatchesRegularExpression

      public static boolean checkIfStringMatchesRegularExpression(String value, String regularExpression)
    • checkIfStringMatchesAsteriskExpression

      public static boolean checkIfStringMatchesAsteriskExpression(String value, String asterixExpression)
    • checkIfStringMatchesAsteriskExpression

      public static boolean checkIfStringMatchesAsteriskExpression(String value, String asterixExpression, boolean ignoreCase)
    • checkIfStringMatchesSearchStringAND

      public static boolean checkIfStringMatchesSearchStringAND(String s, String searchString)
      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

      public static boolean checkIfStringMatchesSearchStringOR(String s, String searchString)
      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

      public static boolean checkIfSimpleDataType(Class c)
    • convertStringIntoObject

      public static Object convertStringIntoObject(String attrValue, Class attrClass)
    • convertStringIntoEnum

      public static Object convertStringIntoEnum(String attrValue, Class attrClass)
    • convertStringIntoEnum

      public static Object convertStringIntoEnum(String attrValue, Class attrClass, boolean withError)
    • convertObject2DisplayString

      public static String convertObject2DisplayString(Object value, String format, String formatmask, String timezone, boolean convertHTML)
    • 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 method convertObject2DisplayString(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 of convertObject2DisplayString(Object, String, String, String, boolean, boolean) with possibility to pass Locale.
    • convertObject2ValueString

      public static String convertObject2ValueString(Object o)
      Converts object into string that can be transferred to the client.
    • getPreferredClassForFieldFormat

      public static Class getPreferredClassForFieldFormat(String format, String timezone)
    • getPreferredClassForFieldFormat

      public static Class getPreferredClassForFieldFormat(String format, String timezone, boolean returnNullIfUnknown)
    • rightScale

      public static BigDecimal rightScale(BigDecimal value, int numberOfFractionDigits)
      Converts a big decimal according to formatmask.
    • decodeTextSelectionInfo

      public static TextSelectionInfo decodeTextSelectionInfo(String s)
    • encodeTextSelectionInfo

      public static String encodeTextSelectionInfo(TextSelectionInfo value)
    • truncateString

      public static String truncateString(String s, int limit)
    • concatenateStrings

      public static String concatenateStrings(List<String> items)
      Memory-optimized concatenation of strings.
    • removeAllHtmlTagsIfHtmlString

      public static String removeAllHtmlTagsIfHtmlString(String html)
    • removeAllHtmlTags

      public static String removeAllHtmlTags(String html)
    • removeDoubleSpacesAndTrim

      public static String removeDoubleSpacesAndTrim(String s)
    • toLowerCaseId

      public static String toLowerCaseId(String s)
    • toUpperCaseId

      public static String toUpperCaseId(String s)
    • toLowerCaseText

      public static String toLowerCaseText(String s)
    • toUpperCaseText

      public static String toUpperCaseText(String s)
    • findFormatter

      public static Format findFormatter(Object value, String format, String formatmask, String timezone, String language, String country)
    • getNumberOfDecimals

      public static int getNumberOfDecimals(String formatmask)
    • checkIfFormatIsNumeric

      public static boolean checkIfFormatIsNumeric(String format)
    • checkIfFormatIsDate

      public static boolean checkIfFormatIsDate(String format)
    • checkIfFormatIsBoolean

      public static boolean checkIfFormatIsBoolean(String format)
    • convertHexCodeToChar

      public static char convertHexCodeToChar(String hexcode)
    • checkIfXMLIsValid

      public static boolean checkIfXMLIsValid(String m_content)
    • encodeURLPart

      public static String encodeURLPart(String urlPart)
    • rightSizeLineBreaks

      public static String rightSizeLineBreaks(String text)
      Ensure that all carriage returns are "\r\n" definitions.
    • approveFileName

      public static String approveFileName(String name)
    • convertFileNameToCanonical

      public static String convertFileNameToCanonical(String fileName, boolean isDirectory)
    • replaceSystemProperties

      public static String replaceSystemProperties(String s, boolean encodeToXml)
      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 using System.getenv(String)) and "${sys.xxxxx}" for system variables (which are resolved using System.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

      public static String removeLeadingXMLDeclaration(String xml)
      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

      public static Source convertStringIntoXMLSource(String xml)
    • getLinesOfText

      public static List<String> getLinesOfText(String text)
    • buildTimeStamp

      public static String buildTimeStamp()
    • convertStringIntoFilePath

      public static String convertStringIntoFilePath(String name)
      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

      public static String convertStringIntoFilePath(String name, boolean lowerCase)
      Extended version of convertStringIntoFilePath(String), with explicit definition if to convert to lowercase or not.
    • convertStringIntoFileName

      public static String convertStringIntoFileName(String name)
      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

      public static String convertStringIntoFileName(String name, boolean lowerCase)
      Extended version of convertStringIntoFileName(String), with explicit definition if to convert to lowercase or not.
    • removeDirectoryPathAndExtensionFromFileName

      public static String removeDirectoryPathAndExtensionFromFileName(String name)
    • removeExtensionFromFileName

      public static String removeExtensionFromFileName(String name)
    • removeDirectoryPathFromFileName

      public static String removeDirectoryPathFromFileName(String name)
    • removeFileNameFromDirectoryPath

      public static String removeFileNameFromDirectoryPath(String name)
    • createEmptyString

      public static String createEmptyString(int numberOfCharacters)