Class CommonUtils

java.lang.Object
rs.baselib.util.CommonUtils

public class CommonUtils extends Object
Common Utils.
Author:
ralph
  • Field Details

    • DEFAULT_CONNECT_TIMEOUT

      public static int DEFAULT_CONNECT_TIMEOUT
      Default timeout for connecting to URLs (10sec)
    • DEFAULT_READ_TIMEOUT

      public static int DEFAULT_READ_TIMEOUT
      Default timeout for reading from URLs (20sec)
    • ALPHA_CHARS

      public static final String ALPHA_CHARS
      alpha chars (uper and lower case letters)
      See Also:
    • NUM_CHARS

      public static final String NUM_CHARS
      numeric chars (0-9)
      See Also:
    • SPECIAL_CHARS

      public static final String SPECIAL_CHARS
      special chars (!\"&/()=?;*+'#;,:._-<>)
      See Also:
    • ALPHA_NUM_CHARS

      public static final String ALPHA_NUM_CHARS
      alpha and numeric chars
      See Also:
    • ALPHA_NUM_SPECIAL_CHARS

      public static final String ALPHA_NUM_SPECIAL_CHARS
      alpha and numeric and special chars
      See Also:
  • Constructor Details

    • CommonUtils

      public CommonUtils()
  • Method Details

    • DATE_FORMATTER

      public static DateFormat DATE_FORMATTER()
      The formatter for dates (see DateFormat.SHORT).
      Returns:
      the formatter
    • DATE_TIME_FORMATTER

      public static DateFormat DATE_TIME_FORMATTER()
      The formatter for dates incl. times (see DateFormat.SHORT).
      Returns:
      the formatter
    • SIMPLE_NUMBER_FORMATTER

      public static NumberFormat SIMPLE_NUMBER_FORMATTER()
      Formatter for real numbers.
      Returns:
      the formatter
    • SIMPLE_INT_FORMATTER

      public static NumberFormat SIMPLE_INT_FORMATTER()
      Formatter for integers.
      Returns:
      the formatter
    • toString

      public static String toString(String o)
      Formats the string for display.
      Parameters:
      o - the category
      Returns:
      string display
    • toString

      public static String toString(float amount)
      Formats the money value.
      Parameters:
      amount - amount to be formatted
      Returns:
      formatted string
    • toString

      public static String toString(byte[] b)
      Generates a string presentation of the given bytes.
      Parameters:
      b - byte array
      Returns:
      string representation (Hex)
    • toString

      public static String toString(Object[] o)
      Generates a string presentation of the given objects.
      Parameters:
      o - object array
      Returns:
      string representation
    • equals

      public static boolean equals(Object o1, Object o2)
      Checks for equality null-safe.
      Parameters:
      o1 - object 1
      o2 - object 2
      Returns:
      true when both values are equal
    • equalsIgnoreCase

      public static boolean equalsIgnoreCase(String o1, String o2)
      Checks strings for equality null-safe and case ignore.

      Strings will not be trimmed before test.

      Parameters:
      o1 - string 1
      o2 - string 2
      Returns:
      true when both values are equal
    • equalsIgnoreCase

      public static boolean equalsIgnoreCase(String o1, String o2, boolean trim)
      Checks strings for equality null-safe and case ignore.
      Parameters:
      o1 - string 1
      o2 - string 2
      trim - whether to trim strings before comparison
      Returns:
      true when both values are equal
    • isEmpty

      public static boolean isEmpty(String s)
      Returns true when the given string is null or - when trimmed - empty.
      Parameters:
      s - the string to be checked
      Returns:
      true when string must be regarded as empty
    • isEmpty

      public static boolean isEmpty(String s, boolean trim)
      Returns true when the given string is null empty.
      Parameters:
      s - the string to be checked
      trim - whether whitespaces shall be trimmed first
      Returns:
      true when string must be regarded as empty
    • trim

      public static String trim(String s)
      Trims the string by removing whitespaces and newlines from begin and end of the string.
      Parameters:
      s - - the string to trim
      Returns:
      the trimmed string (null if input was null)
      Since:
      3.1.0
    • isAllowedTrimmingChar

      public static boolean isAllowedTrimmingChar(char c)
      Returns true when the given character shall be kept when trimming a string.
      Parameters:
      c - - character to check
      Returns:
      true when character is allowed
      Since:
      3.1.0
    • isCompatibleVersion

      public static boolean isCompatibleVersion(String minVersion, String maxVersion, String version)
      Returns true if version is in range of minVersion and maxVersion. Note that 1.2.0 is greater than 1.2
      Parameters:
      minVersion - - minimum required version (can be null)
      maxVersion - - maximum required version (can be null)
      version - - version to check
      Returns:
      true when version is within range
    • compareVersion

      public static int compareVersion(String v1, String v2)
      Compares software versions.
      Parameters:
      v1 - - version 1
      v2 - - version 2
      Returns:
      -1 if v1 < v2, 1 if v1 > v2, 0 if v1 = v2
    • compareVersion

      public static int compareVersion(String[] v1, String[] v2)
      Compares versions.
      Parameters:
      v1 - - version 1 divided into separate parts
      v2 - - version 2 divided into separate parts
      Returns:
      -1 if v1 < v2, 1 if v1 > v2, 0 if v1 = v2
    • join

      public static String join(String separator, Collection<?> parts)
      Makes a join of a collection.
      Parameters:
      separator - - the string to be used inbetween parts
      parts - - the collection to join
      Returns:
      the joined string
    • join

      public static String join(String separator, String[] parts)
      Makes a join of a string array.
      Parameters:
      separator - - the string to be used inbetween parts
      parts - - the parts to join
      Returns:
      the joined string
    • join

      public static String join(String separator, Object[] parts)
      Makes a join of an object array.
      Parameters:
      separator - - the string to be used inbetween parts
      parts - - the parts to join
      Returns:
      the joined string
      Since:
      1.2.9
    • join

      public static String join(String separator, String[] parts, int startIndex)
      Makes a join of a string array.
      Parameters:
      separator - - the string to be used inbetween parts
      parts - - the parts to join
      startIndex - - starting index (negative values not allowed)
      Returns:
      the joined string
    • join

      public static String join(String separator, Collection<?> parts, int startIndex)
      Makes a join of a collection.
      Parameters:
      separator - - the string to be used inbetween parts
      parts - - the collection to join
      startIndex - - starting index (negative values not allowed)
      Returns:
      the joined string
      Since:
      1.2.9
    • join

      public static String join(String separator, Object[] parts, int startIndex)
      Makes a join of an object array.
      Parameters:
      separator - - the string to be used inbetween parts
      parts - - the parts to join
      startIndex - - starting index (negative values not allowed)
      Returns:
      the joined string
      Since:
      1.2.9
    • join

      public static String join(String separator, String[] parts, int startIndex, int endIndex)
      Makes a join of a string array.
      Parameters:
      separator - - the string to be used inbetween parts
      parts - - the parts to join
      startIndex - - starting index (negative values not allowed)
      endIndex - - endIndex (bigger values than number or array elements have no effect)
      Returns:
      the joined string
    • join

      public static String join(String separator, Object[] parts, int startIndex, int endIndex)
      Makes a join of an object array.
      Parameters:
      separator - - the string to be used inbetween parts
      parts - - the parts to join
      startIndex - - starting index (negative values not allowed)
      endIndex - - endIndex (bigger values than number or array elements have no effect)
      Returns:
      the joined string
      Since:
      1.2.9
    • join

      public static String join(String separator, Collection<?> parts, int startIndex, int endIndex)
      Makes a join of a collection.
      Parameters:
      separator - - the string to be used inbetween parts
      parts - - the collection to join
      startIndex - - starting index (negative values not allowed)
      endIndex - - endIndex (bigger values than number or collection elements have no effect)
      Returns:
      the joined string
      Since:
      1.2.9
    • split

      public static Collection<String> split(String s)
      Splits the string using comma as separation char.
      Parameters:
      s - - the string to split
      Returns:
      collection of separated entries
      Since:
      3.1.0
    • split

      public static Collection<String> split(String s, Collection<String> defaultCollection)
      Splits the string using comma as separation char.
      Parameters:
      s - - the string to split
      defaultCollection - - the default collection when input is empty.
      Returns:
      collection of separated entries or the default collection
      Since:
      3.1.0
    • split

      public static Collection<String> split(String s, String delim, Collection<String> defaultCollection)
      Splits the string using comma as separation char.
      Parameters:
      s - - the string to split
      delim - - the delimiter character
      defaultCollection - - the default collection when input is empty.
      Returns:
      collection of separated entries or the default collection
      Since:
      3.1.0
    • split

      public static <T extends Enum<T>> Collection<T> split(String s, Class<T> enumClass)
      Splits the string and returns a collection of Enum values from specified class.

      Useful to convert a string into a collection of enum values.

      Type Parameters:
      T - - the Enum type
      Parameters:
      s - - the string to split
      enumClass - - the Enum class
      Returns:
      the list of Enum values
      Since:
      3.1.0
    • split

      public static <T extends Enum<T>> Collection<T> split(String s, String delim, Class<T> enumClass)
      Splits the string (by commas) and returns a collection of Enum values from specified class.

      Useful to convert a string into a collection of enum values.

      Type Parameters:
      T - - the Enum type
      Parameters:
      s - - the string to split
      delim - - the delimiter to split upon
      enumClass - - the Enum class
      Returns:
      the list of Enum values
      Since:
      3.1.0
    • newList

      @SafeVarargs public static <T> List<T> newList(T... elems)
      Creates a list from elements.
      Type Parameters:
      T - - the element type
      Parameters:
      elems - - the elements
      Returns:
      new List of elements
      Since:
      3.1.0
    • newSet

      @SafeVarargs public static <T> Set<T> newSet(T... elems)
      Creates a set from elements.
      Type Parameters:
      T - - the element type
      Parameters:
      elems - - the elements
      Returns:
      new Set of elements
      Since:
      3.1.0
    • debugObject

      public static String debugObject(Object o)
      Recursively debugs objects.
      Parameters:
      o - object to debug
      Returns:
      the debug string
      Since:
      1.2.3
    • debugObject

      public static void debugObject(StringBuffer s, Object o)
      Recursively debugs objects and adds this in the string buffer.
      Parameters:
      s - string buffer to enhance
      o - object to debug
    • debugObject

      public static void debugObject(StringBuilder s, Object o)
      Recursively debugs objects and adds this in the string builder.
      Parameters:
      s - string builder to enhance
      o - object to debug
      Since:
      1.2.3
    • getUnixTimestamp

      public static long getUnixTimestamp()
      Returns the current time as UNIX timestamp.
      Returns:
      time in seconds since January 1st, 1970, 00:00:00 UTC.
    • getUnixTimestamp

      public static long getUnixTimestamp(Date date)
      Returns the given date as UNIX timestamp.
      Parameters:
      date - date object.
      Returns:
      time in seconds since January 1st, 1970, 00:00:00 UTC.
    • getUnixTimestamp

      public static long getUnixTimestamp(long time)
      Returns the given Java time as UNIX timestamp.
      Parameters:
      time - Java timestamp
      Returns:
      time in seconds since January 1st, 1970, 00:00:00 UTC.
    • iterable

      public static <T> Iterable<T> iterable(Iterator<T> iterator)
      Returns an iterable for the given iterator.
      Type Parameters:
      T - type of objects in the iterator
      Parameters:
      iterator - the iterator to be wrapped
      Returns:
      the iterable.
    • getStackTrace

      public static List<String> getStackTrace(int ignoreLines)
      Returns the current stacktrace.
      Parameters:
      ignoreLines - the number of lines to be ignored at the top of the trace
      Returns:
      the stacktrace
    • stdoutStackTrace

      public static void stdoutStackTrace()
      Dumps the stacktrace so stdout.
    • stderrStackTrace

      public static void stderrStackTrace()
      Dumps the stacktrace so stderr.
    • printStackTrace

      public static void printStackTrace(PrintStream out, int ignoreLines)
      Dumps the stacktrace into the print stream.
      Parameters:
      out - the stream to be used
      ignoreLines - the number of lines to be ignored at top of trace
    • errorStackTrace

      public static void errorStackTrace(Logger log)
      Dumps the stacktrace in ERROR mode.
      Parameters:
      log - the logger to be used
    • infoStackTrace

      public static void infoStackTrace(Logger log)
      Dumps the stacktrace in INFO mode.
      Parameters:
      log - the logger to be used
    • debugStackTrace

      public static void debugStackTrace(Logger log)
      Dumps the stacktrace in DEBUG mode.
      Parameters:
      log - the logger to be used
    • traceStackTrace

      public static void traceStackTrace(Logger log)
      Dumps the stacktrace in TRACE mode.
      Parameters:
      log - the logger to be used
    • loadProperties

      public static Properties loadProperties(URI uri) throws IOException
      Loads a property file.

      The URI resource is in a simple line-oriented format as specified in Properties.load(Reader) and is assumed to use the ISO 8859-1 character encoding; that is each byte is one Latin1 character. Characters not in Latin1, and certain special characters, are represented in keys and elements using Unicode escapes as defined in section 3.3 of The Java Language Specification.

      Parameters:
      uri - the URI to load from
      Returns:
      the properties
      Throws:
      IOException - when file cannot be loaded
    • loadProperties

      public static Properties loadProperties(URL url) throws IOException
      Loads a property file.

      The URL resource is in a simple line-oriented format as specified in Properties.load(Reader) and is assumed to use the ISO 8859-1 character encoding; that is each byte is one Latin1 character. Characters not in Latin1, and certain special characters, are represented in keys and elements using Unicode escapes as defined in section 3.3 of The Java Language Specification.

      Parameters:
      url - the URL to load from
      Returns:
      the properties
      Throws:
      IOException - when file cannot be loaded
    • loadProperties

      public static Properties loadProperties(File file) throws IOException
      Loads a property file.

      The File resource is in a simple line-oriented format as specified in Properties.load(Reader) and is assumed to use the ISO 8859-1 character encoding; that is each byte is one Latin1 character. Characters not in Latin1, and certain special characters, are represented in keys and elements using Unicode escapes as defined in section 3.3 of The Java Language Specification.

      Parameters:
      file - the file to load
      Returns:
      the properties
      Throws:
      IOException - when file cannot be loaded
    • loadProperties

      public static Properties loadProperties(String file) throws IOException
      Loads a property file.

      The file resource is in a simple line-oriented format as specified in Properties.load(Reader) and is assumed to use the ISO 8859-1 character encoding; that is each byte is one Latin1 character. Characters not in Latin1, and certain special characters, are represented in keys and elements using Unicode escapes as defined in section 3.3 of The Java Language Specification.

      Parameters:
      file - the file to load
      Returns:
      the properties
      Throws:
      IOException - when file cannot be loaded
    • loadProperties

      public static void loadProperties(Properties props, File file) throws IOException
      Loads a property file.

      The File resource is in a simple line-oriented format as specified in Properties.load(Reader) and is assumed to use the ISO 8859-1 character encoding; that is each byte is one Latin1 character. Characters not in Latin1, and certain special characters, are represented in keys and elements using Unicode escapes as defined in section 3.3 of The Java Language Specification.

      Parameters:
      props - the properties object
      file - the file to load
      Throws:
      IOException - when file cannot be loaded
    • loadProperties

      public static void loadProperties(Properties props, URI uri) throws IOException
      Loads a property file.

      The URI resource is in a simple line-oriented format as specified in Properties.load(Reader) and is assumed to use the ISO 8859-1 character encoding; that is each byte is one Latin1 character. Characters not in Latin1, and certain special characters, are represented in keys and elements using Unicode escapes as defined in section 3.3 of The Java Language Specification.

      Parameters:
      props - the properties object
      uri - the uri to load
      Throws:
      IOException - when file cannot be loaded
    • loadProperties

      public static void loadProperties(Properties props, URL url) throws IOException
      Loads a property file.

      The URL resource is in a simple line-oriented format as specified in Properties.load(Reader) and is assumed to use the ISO 8859-1 character encoding; that is each byte is one Latin1 character. Characters not in Latin1, and certain special characters, are represented in keys and elements using Unicode escapes as defined in section 3.3 of The Java Language Specification.

      Parameters:
      props - the properties object
      url - the url to load
      Throws:
      IOException - when file cannot be loaded
    • loadProperties

      public static void loadProperties(Properties props, InputStream inputStream) throws IOException
      Loads a property file.

      The input stream is in a simple line-oriented format as specified in Properties.load(Reader) and is assumed to use the ISO 8859-1 character encoding; that is each byte is one Latin1 character. Characters not in Latin1, and certain special characters, are represented in keys and elements using Unicode escapes as defined in section 3.3 of The Java Language Specification.

      Parameters:
      props - the properties object
      inputStream - the stream to load from
      Throws:
      IOException - when file cannot be loaded
    • loadProperties

      public static void loadProperties(Properties props, String file) throws IOException
      Loads a property file.

      The file resource is in a simple line-oriented format as specified in Properties.load(Reader) and is assumed to use the ISO 8859-1 character encoding; that is each byte is one Latin1 character. Characters not in Latin1, and certain special characters, are represented in keys and elements using Unicode escapes as defined in section 3.3 of The Java Language Specification.

      Parameters:
      props - the properties object
      file - the file to load
      Throws:
      IOException - when file cannot be loaded
    • storeProperties

      public static void storeProperties(Properties props, File file) throws IOException
      Stores a property file.
      Parameters:
      props - the properties object
      file - the file to load
      Throws:
      IOException - when file cannot be stored
    • storeProperties

      public static void storeProperties(Properties props, String file) throws IOException
      Stores a property file.
      Parameters:
      props - the properties object
      file - the file to load
      Throws:
      IOException - when file cannot be stored
    • getConnectTimeout

      public static int getConnectTimeout()
      Returns the URL connect timeout.
      Returns:
      the connectTimeout
    • setConnectTimeout

      public static void setConnectTimeout(int connectTimeout)
      Sets the URL connect timeout.
      Parameters:
      connectTimeout - the connectTimeout to set
    • getReadTimeout

      public static int getReadTimeout()
      Returns the URL read timeout.
      Returns:
      the readTimeout
    • setReadTimeout

      public static void setReadTimeout(int readTimeout)
      Sets the URL read timeout.
      Parameters:
      readTimeout - the readTimeout to set
    • loadContent

      public static String loadContent(URI uri) throws IOException
      Loads the content of the URI as a string.
      Parameters:
      uri - URI to be loaded
      Returns:
      the content of the URI
      Throws:
      IOException - when content of URI cannot be loaded
    • loadContent

      public static String loadContent(URI uri, Charset charset) throws IOException
      Loads the content of the URI as a string.
      Parameters:
      uri - URI to be loaded
      charset - the charset of the content (null for default charset)
      Returns:
      the content of the URI
      Throws:
      IOException - when content of URI cannot be loaded
    • loadContent

      public static String loadContent(URL url) throws IOException
      Loads the content of the URL as a string.
      Parameters:
      url - URL to be loaded
      Returns:
      the content of the URL
      Throws:
      IOException - when content of URL cannot be loaded
    • loadContent

      public static String loadContent(URL url, Charset charset) throws IOException
      Loads the content of the URL as a string.
      Parameters:
      url - URL to be loaded
      charset - the charset of the content (null for default charset)
      Returns:
      the content of the URL
      Throws:
      IOException - when content of URL cannot be loaded
    • loadContent

      public static String loadContent(URLConnection con, Charset charset) throws IOException
      Loads the content of the URL as a string.
      Parameters:
      con - URL connection to be used
      charset - the charset of the content (null for default charset)
      Returns:
      the content of the URL
      Throws:
      IOException - when content of URL cannot be loaded
    • loadContent

      public static String loadContent(String name) throws IOException
      Loads the content of a file as a string.
      Parameters:
      name - name of file to be loaded
      Returns:
      the content of the file
      Throws:
      IOException - when content of file cannot be loaded
    • loadContent

      public static String loadContent(String name, Charset charset) throws IOException
      Loads the content of a file as a string.
      Parameters:
      name - name of file to be loaded
      charset - the charset of the content (null for default charset)
      Returns:
      the content of the file
      Throws:
      IOException - when content of file cannot be loaded
    • loadContent

      public static String loadContent(File f) throws IOException
      Loads the content of a file as a string.
      Parameters:
      f - file to be loaded
      Returns:
      the content of the file
      Throws:
      IOException - when content of file cannot be loaded
    • loadContent

      public static String loadContent(File f, Charset charset) throws IOException
      Loads the content of a file as a string.
      Parameters:
      f - file to be loaded
      charset - the charset of the content (null for default charset)
      Returns:
      the content of the file
      Throws:
      IOException - when content of file cannot be loaded
    • loadContent

      public static String loadContent(InputStream in) throws IOException
      Loads the content of a stream as a string.
      Parameters:
      in - stream to be loaded
      Returns:
      the content of the stream
      Throws:
      IOException - when content of stream cannot be loaded
    • loadContent

      public static String loadContent(InputStream in, Charset charset) throws IOException
      Loads the content of a stream as a string.
      Parameters:
      in - stream to be loaded
      charset - the charset of the content (null for default charset)
      Returns:
      the content of the stream
      Throws:
      IOException - when content of stream cannot be loaded
    • loadContent

      public static String loadContent(Reader reader) throws IOException
      Loads the content of a reader as a string.
      Parameters:
      reader - reader to be loaded
      Returns:
      the content of the reader
      Throws:
      IOException - when content of reader cannot be loaded
    • writeContent

      public static void writeContent(String name, String content) throws IOException
      Writes the string to a file.
      Parameters:
      name - name of file to be written to
      content - the content to be written
      Throws:
      IOException - when content cannot be written
    • writeContent

      public static void writeContent(String name, String content, Charset charset) throws IOException
      Writes the string to a file.
      Parameters:
      name - name of file to be written to
      content - the content to be written
      charset - the charset of the content (null for default charset)
      Throws:
      IOException - when content cannot be written
    • writeContent

      public static void writeContent(File f, String content) throws IOException
      Writes the string to a file.
      Parameters:
      f - file to be written to
      content - the content to be written
      Throws:
      IOException - when content cannot be written
    • writeContent

      public static void writeContent(File f, String content, Charset charset) throws IOException
      Writes the string to a file.
      Parameters:
      f - file to be written to
      content - the content to be written
      charset - the charset of the content (null for default charset)
      Throws:
      IOException - when content cannot be written
    • writeContent

      public static void writeContent(OutputStream out, String content) throws IOException
      Writes the string to a stream.
      Parameters:
      out - stream to be written to
      content - the content to be written
      Throws:
      IOException - when content cannot be written
    • writeContent

      public static void writeContent(OutputStream out, String content, Charset charset) throws IOException
      Writes the string to a stream.
      Parameters:
      out - stream to be written to
      content - the content to be written
      charset - the charset of the content (null for default charset)
      Throws:
      IOException - when content cannot be written
    • writeContent

      public static void writeContent(Writer writer, String content) throws IOException
      Writes the string to a writer.
      Parameters:
      writer - writer to be written to
      content - the content to be written
      Throws:
      IOException - when content cannot be written
    • isWindows

      public static boolean isWindows()
      Tells whether runtime is a Windows system.
      Returns:
      true when OS is a Windows system
    • isMac

      public static boolean isMac()
      Tells whether runtime is a Mac system.
      Returns:
      true when OS is a Mac system
    • isUnix

      public static boolean isUnix()
      Tells whether runtime is a Unix system.
      Returns:
      true when OS is a Unix system
    • isSolaris

      public static boolean isSolaris()
      Tells whether runtime is a Windows system.
      Returns:
      true when OS is a Windows system
    • isEmail

      public static boolean isEmail(String s)
      Checks validity of an email address.
      Parameters:
      s - the string to be checked
      Returns:
      true when string is a valid email address
      Since:
      1.2.9
    • getOS

      public static String getOS()
      Returns the OS name.
      Returns:
      the OS name as returned by System.getProperty("os.name")
    • setAnchor

      public static URL setAnchor(URL url, String anchor)
      Set the anchor id for at the given URL.
      Parameters:
      url - url to be modified
      anchor - new anchor to be set
      Returns:
      the modified URL but other components are kept
    • replaceEnvVariables

      public static String replaceEnvVariables(String s)
      Replaces environment variables.

      The variables must be formed as $ENV{<name>}, e.g. $ENV{PATH}.

      Parameters:
      s - string to be analyzed (can be null or empty)
      Returns:
      string with variables replaced
    • replaceRuntimeVariables

      public static String replaceRuntimeVariables(String s)
      Replaces environment variables.

      The variables must be formed as $SYSTEM{<name>}, e.g. $SYSTEM{user.home}.

      Parameters:
      s - string to be analyzed (can be null or empty)
      Returns:
      string with variables replaced
    • replaceVariables

      public static String replaceVariables(String s)
      Replaces environment and system variables.

      The variables must be formed as:

      • $ENV{<name>}, e.g. $ENV{PATH}
      • $SYSTEM{<name>}, e.g. $SYSTEM{user.home}
      Parameters:
      s - string to be analyzed (can be null or empty)
      Returns:
      string with variables replaced
    • setMarkers

      public static String setMarkers(String template, String prefix, Object valueObject)
      Sets markers in a template.

      The markers must be like {@prefix:attribute-name}. The attribute value is the value of the getter method of the value object.

      Parameters:
      template - the template
      prefix - the marker prefix
      valueObject - the object that contains values
      Returns:
      the template with markers replaced
    • generateRandomString

      public static String generateRandomString()
      Generates a random string of length 10 with ALPHA_NUM_SPECIAL_CHARS.
      Returns:
      the generated random string
      Since:
      4.0.2
    • generateRandomString

      public static String generateRandomString(int length)
      Generates a random string with ALPHA_NUM_SPECIAL_CHARS.
      Parameters:
      length - - length of string (using 10 if less than 1)
      Returns:
      the generated random string
      Since:
      4.0.2
    • generateRandomString

      public static String generateRandomString(String allowedChars)
      Generates a random string of length 10.
      Parameters:
      allowedChars - - allowed chars (using ALPHA_NUM_SPECIAL_CHARS when null)
      Returns:
      the generated random string
      Since:
      4.0.2
    • generateRandomString

      public static String generateRandomString(String allowedChars, int length)
      Generates a random string.
      Parameters:
      allowedChars - - allowed chars (using ALPHA_NUM_SPECIAL_CHARS when null)
      length - - length of string (using 10 if less than 1)
      Returns:
      the generated random string
      Since:
      4.0.2