Class StringTools

java.lang.Object
com.webmethods.caf.common.StringTools

public class StringTools extends Object
Various string utility functions and operations
  • Field Details

  • Constructor Details

    • StringTools

      public StringTools()
  • Method Details

    • hasSuccess

      public static String hasSuccess(Object instance)
      Checks instance to be not null, and returns either success or failed string
      Parameters:
      instance - object instance to check
    • getListFromDelimitedString

      public static List<String> getListFromDelimitedString(String data, String delimiter)
      Parses data with the specified delimiter
      Parameters:
      data - Original data to parse
      delimiter - Delimiter to use for data parsing
      Returns:
      LinkedList of tokens parsed, delimiters are not returned
    • getIntArrayFromDelimitedString

      public static int[] getIntArrayFromDelimitedString(String data, String delimiter)
      Parses string with the specified delimiter and returns array of ints as a result of parsing. Of course this appliable only when you do know that string contains integers
      Parameters:
      data - Original data to parse
      delimiter - Delimiter to use for data parsing
      Returns:
      array of integers
    • getArrayFromCsvString

      public static String[] getArrayFromCsvString(String csv)
      Parses comma (",") delimited string to string array. No quotes (") supported
      Parameters:
      csv - Comma separated values
      Returns:
      array of String extracted from line
    • getListFromCsv

      public static List<String> getListFromCsv(String value)
      Parses comma delimited string to List of String instances
      Parameters:
      value - Comma delimited string to parse
      Returns:
      List of Strings extractecd from comma-separated line
    • getListFromCsv

      public static List<String> getListFromCsv(String value, boolean allowDups)
      Parses comma delimited string to List of String instances
      Parameters:
      value - Comma delimited string to parse
      allowDups - true to allow duplicates within the list
      Returns:
      List of Strings extractecd from comma-separated line
    • getLongsListFromCsv

      public static List<Long> getLongsListFromCsv(String value)
      Parses comma delimited string to List of Long instances
      Parameters:
      value - Comma delimited string to parse
      Returns:
      List of Longs
    • getCsvFromList

      public static String getCsvFromList(List<?> list)
      Constructs string from list of values
      Parameters:
      list - source list of values
      Returns:
      Comma-separated string as a result of values concatenation
    • getFirstSegment

      public static String getFirstSegment(String value, String separator)
      Get first string segment separated by passed separator
      Parameters:
      value - initial string
      separator - is separator string
      Returns:
      stripped segment or null
    • getLastSegment

      public static String getLastSegment(String value, String separator)
      Get last string segment separated by passed separator
      Parameters:
      value - initial string
      separator - is separator string
      Returns:
      stripped segment or null
    • getLastSegment

      public static String getLastSegment(String value, String separator, boolean includeSeperator)
      Get last string segment separated by passed separator
      Parameters:
      value - initial string
      separator - is separator string
      includeSeperator - true to include the seperator character in the result, false otherwise
      Returns:
      stripped segment or null
    • getSegment

      public static String getSegment(String str, String separator, int segment)
      Returns the segment, null if not found, first segment is segment 0
      Parameters:
      str - Source string
      separator - Parsing separator
      segment - String segment number
      Returns:
      Specified segment of the string extracted
    • stripFirstSegment

      public static String stripFirstSegment(String value, String separator)
      Strips string first segment, defined by separator and returns stripped string
      Parameters:
      value - initial string
      separator - is separator string
      Returns:
      stripped value string
    • stripLastSegment

      public static String stripLastSegment(String value, String separator)
      Strips string last segment, defined by separator and returns stripped string
      Parameters:
      value - initial string
      separator - is separator string
      Returns:
      stripped value string
    • isEmpty

      public static boolean isEmpty(String str)
      Verifies whether passed string is empty or not.
      Parameters:
      str - Source string to analyze
      Returns:
      True, if string is empty, False - otherwise
    • notEmpty

      public static boolean notEmpty(String str)
      Checks that string is not empty. Can be opposed to usage of isEmpty(java.lang.String)
      Parameters:
      str - String value to analyze
      Returns:
      true, if string is empty, false otherwise
      See Also:
    • removeCR

      public static String removeCR(String s)
      Replaces all CR(\n) symbols in string via " "(space) character
      Parameters:
      s - Source string
      Returns:
      String with all CR(\n) chars replaced with space(" ")
    • parseIntDef

      public static int parseIntDef(String s, int def)
      Parses string and returns converted integer value. If parsing failes the default value is taken.
      Parameters:
      s - string to parse
      def - default int value, if string is unparsable
      Returns:
      int as a result string to int conversion
    • parseBooleanDef

      public static boolean parseBooleanDef(String s, boolean def)
      Parses string and returns converted boolean value. If parsing fails the default value is taken.
      Parameters:
      s - String to parse
      def - Default boolean value
      Returns:
      boolean value that is parsed from the string
    • parseLongDef

      public static long parseLongDef(String s, long def)
      Parses string and returns converted boolean value. If parsing fails the default value is taken.
      Parameters:
      s - String to parse
      def - Default boolean value
      Returns:
      boolean value that is parsed from the string
    • parseParameters

      public static void parseParameters(String url, int start, Map<String,String> parameters)
      Adds parameters from url query string to specified map.
      Parameters:
      url - Url with query string.
      start - Index at which to start parse (ie url.indexOf('?')).
      parameters - Map into which to put parsed param name=value pairs.
    • change

      public static String change(String s, String oldp, String newp, int start, int maxChanges, boolean ignoreCase)
      Changes occurrences of a specified pattern to a replacement string. The maximum number of changes and a starting position can be specified. You can specify that case should be ignored.
      Parameters:
      s - the input string
      oldp - the pattern to be replaced
      newp - the replacement string
      start - the starting position for the search
      maxChanges - the maximum number of changes
      ignoreCase - if true case is ignored when comparing characters
      Returns:
      a string with the specified patterns changed.
    • change

      public static String change(String s, String oldp, String newp, int start, boolean ignoreCase)
      Changes occurrences of a specified pattern to a replacement string. The starting position can be specified. You can specify that case should be ignored.
      Parameters:
      s - the input string
      oldp - the pattern to be replaced
      newp - the replacement string
      start - the starting position for the search
      ignoreCase - if true case is ignored when comparing characters
      Returns:
      a string with the specified patterns changed.
    • change

      public static String change(String s, String oldp, String newp, int start, int maxChanges)
      Changes occurrences of a specified pattern to a replacement string. The maximum number of changes and a starting position can be specified.
      Parameters:
      s - the input string
      oldp - the pattern to be replaced
      newp - the replacement string
      start - the starting position for the search
      maxChanges - the maximum number of changes
      Returns:
      a string with the specified patterns changed.
    • change

      public static String change(String s, String oldp, String newp, int start)
      Changes occurrences of a specified pattern to a replacement string. A starting position can be specified.
      Parameters:
      s - the input string
      oldp - the pattern to be replaced
      newp - the replacement string
      start - the starting position for the search
      Returns:
      a string with the specified patterns changed.
    • change

      public static String change(String s, String oldp, String newp, boolean ignoreCase)
      Changes occurrences of a specified pattern to a replacement string. You can specify that case should be ignored.
      Parameters:
      s - the input string
      oldp - the pattern to be replaced
      newp - the replacement string
      ignoreCase - if true case is ignored when comparing characters
      Returns:
      a string with the specified patterns changed.
    • change

      public static String change(String s, String oldp, String newp)
      Changes occurrences of a specified pattern to a replacement string.
      Parameters:
      s - the input string
      oldp - the pattern to be replaced
      newp - the replacement string
      Returns:
      a string with the specified patterns changed.
    • occurrencesOf

      public static int occurrencesOf(String s, String c, int start, boolean ignoreCase)
      Returns the number of occurrences of the specified string. You can specify that case should be ignored.
      Parameters:
      s - the string to be inspected
      c - the string to search for
      start - the starting position for the search
      ignoreCase - if true case is ignored when comparing characters
      Returns:
      the number of occurrences of the specified string. If the string is not found -1 is returned.
    • occurrencesOf

      public static int occurrencesOf(String s, int ch, int start)
      counts characters in string, case sensitive
      Parameters:
      s - string to analyze
      ch - character we are looking for
      start - start offset inside the string
      Returns:
      quantity of character occurrences inside the specified string
    • indexOf

      public static int indexOf(String s, String c, int start, boolean ignoreCase)
      Returns the index of the first ocurrence of the specified string. You can specify that case should be ignored.
      Parameters:
      s - the string to be inspected
      c - the string to be searched for
      start - the starting position for the search
      ignoreCase - if true case is ignored when comparing characters
      Returns:
      the index of the first ocurrence of the specified string.
      See Also:
    • equals

      public static boolean equals(char c1, char c2, boolean ignoreCase)
      Checks if two characters are equal. You can specify that case should be ignored.
      Parameters:
      c1 - first character
      c2 - second character
      ignoreCase - if true case is ignored when comparing characters
      Returns:
      true if the characters are equal, false otherwise
      See Also:
    • equals

      public static boolean equals(String s1, String s2, boolean ignoreCase)
      Checks if two strings are equal. You can specify that case should be ignored.
      Parameters:
      s1 - first string
      s2 - second string
      ignoreCase - if true case is ignored when comparing string
      Returns:
      true if the characters are equal, false otherwise, true if they are both null
      See Also:
    • notEquals

      public static boolean notEquals(String s1, String s2, boolean ignoreCase)
      Checks if two strings are NOT equal. You can specify that case should be ignored.
      Parameters:
      s1 - first string
      s2 - second string
      ignoreCase - if true case is ignored when comparing string
      Returns:
      true if the characters are NOT equal, false otherwise, true if they are both null
      See Also:
    • compareStrings

      public static int compareStrings(String s1, String s2, boolean ignoreCase)
      Compare two strings, always treating null as greater than
      Parameters:
      s1 - first string
      s2 - second string
      ignoreCase - if true case is ignored when comparing string
      Returns:
      >0 if greater than <0 if less than, 0 if equal
      See Also:
    • substituteBatch

      public static String substituteBatch(String source, Map<String,String> valuesMap)
      Replace all patterns in the string with the ones given in the given HashMap instance. Example:
       // This string is obtained on run-time. For example, template inner text
       String toChangeIn = "<H1> ${SomeVarName} </H1>\r\n<td>${AnotherVarName}</td>";
       
       hashMap.put("${SomeVarName}", SomeRunTimeVarValue);
       hashMap.put("${AnotherVarName}", AnotherVarRuntime);
       
       String changedString = StringTools.substituteBatch(toChangeIn, hashMap);
       
    • intToHex

      public static String intToHex(int value, boolean padding)
      Convert integer to hex, optionally padding with 0s
      Parameters:
      value - int value to convert
      padding - do we want to pad int with 0's
      Returns:
      String hexadecimal presentation of the specified value (optionally padded)
    • smallIntToHex

      public static String smallIntToHex(int value, boolean padding)
      Convert small int to hex, optionally padding with 0s
      Parameters:
      value - small int value to convert
      padding - do we want to pad int with 0's
      Returns:
      String hexadecimal presentation of the specified value (optionally padded)
    • ensureTrailing

      public static String ensureTrailing(String value, String suffix)
      Ensures that string ends with specified symbol
      Parameters:
      value - string value to ensure
      suffix - suffex to append (if not yet)
      Returns:
      String with guaranteed suffix
    • ensureLeading

      public static String ensureLeading(String value, String prefix)
      Ensures that string starts with specified symbol
      Parameters:
      value - string value to ensure
      prefix - prefix to append (if not yet)
      Returns:
      String with guaranteed prefix
    • toString

      public static String toString(InputStream stream) throws IOException
      Loads stream contents to the stream
      Parameters:
      stream - InputStream to load
      Returns:
      String presentation of the input stream
      Throws:
      IOException
    • toString

      public static String toString(Reader reader)
      Load string from reader
      Parameters:
      reader - Source reader
      Returns:
      String that contains all information from the specified reader
    • toString

      public static String toString(Map<?,?> map, String[] ignoreKeys)
      Prints out a map with key value pairs combined with '=' separated by ',' and surrounded by { and }
      Parameters:
      map - map to be printed
      Returns:
      String representation of map
    • toString

      public static String toString(Map<?,?> map)
      Prints out a map with key value pairs combined with '=' separated by ',' and surrounded by { and }
      Parameters:
      map - map to be printed
      Returns:
      String representation of map
    • toString

      public static String toString(Object[] array)
      To string an array of objects separated by ',' and surrounded by '[' and ']'.
      Parameters:
      array - array to be printed
      Returns:
      String representation of object array
    • toString

      public static String toString(Object object)
      ToString object
      Parameters:
      object - object to be printed
      Returns:
      string representation of object
    • toString

      public static String toString(String[] array)
      Convert array to single string presentation for debugging purposes
      Parameters:
      array - Source string array
      Returns:
      String presentation of the array
    • toString

      public static String toString(Collection<?> collection, String lineSeperator)
      Convert Collection of object to single string for debugging purposes
      Parameters:
      collection - Source data collection
      lineSeperator - Line separator to use
      Returns:
      Single string presentation of the specified Collection
    • toString

      public static String toString(String[] array, String lineSeparator)
      Convert array of strings to single string presentation for debug purposes
      Parameters:
      array - Source array of strings
      lineSeparator - Line separator to delimit items
      Returns:
      Single string array presentation
    • replaceHiAsciChars

      public static String replaceHiAsciChars(String orig, char replacementChar)
      Strips out the hi ascii chars (>127) and replaces them with a replacement char
      Parameters:
      orig - Original string
      replacementChar - Replacement character to use
      Returns:
      Original string with all chars higher than 127 replaced with replacement char
    • replaceChars

      public static String replaceChars(String orig, String chars, char replace)
      Replaces all chars with the replacement char
      Parameters:
      orig - Original string
      chars - Characters we want to replace
      replace - Replacement character
      Returns:
      Modified original string with all chars replaced with replacement character
    • replaceChars

      public static String replaceChars(String orig, String chars, String replace)
      Replaces all chars with the replacement char
      Parameters:
      orig - Original string
      chars - Characters we want to replace
      replace - Replacement character
      Returns:
      Modified original string with all chars replaced with replacement character
    • toBoolean

      public static boolean toBoolean(String value)
      Converts string to boolean. The difference is that is understands "on" and "off" values as true and false respectively
      Parameters:
      value - Source string value to convert
      Returns:
      true or false depending on string content. If string is empty - false is returned
    • wrap

      public static String wrap(String value, String prefix, String postfix)
      Wrap string value with prefix and postfix. Result looks as follows:
        result := prefix + value + postfix
       
      Parameters:
      value - Source string value to wrap
      prefix - Prefix to use
      postfix - Postfix to use
      Returns:
      Original string with specified prefix and postfix
    • unwrap

      public static String unwrap(String value, String prefix, String postfix)
      Unwraps string using selected prefix and postfix
      Parameters:
      value - Previously wrapped string
      prefix - Prefix to use
      postfix - Postfix to use
      Returns:
      Original value used inside wrap(java.lang.String, java.lang.String, java.lang.String) call
      See Also:
    • truncate

      public static String truncate(String value, int maxLength)
      Truncates input string to the specified size
      Parameters:
      value - Source string to analyze
      maxLength - Maximum string length
      Returns:
      Source string truncated using specified size
    • truncateArray

      public static void truncateArray(Object[] values, int[] actions)
      Truncate array of strings using specified list of lengths (actions). Sample usage:
        String[] values = new String[] {
             "one",
             "Some reallllllllllllllllllllly big value",
             "Anotherrrrrrrrrrrrrrrrrrrrrrrrrrrr big value"
        };
       
        int[] actions = new int[] {
             NO_ACTION  // See NO_ACTION
             20,
             20
        };
       
        StringTools.truncateArray(values, actions);
       
      In this sample 1st element of the values will be left unchanged, but all others will be truncated using 20 as a string length limit
      Parameters:
      values - Original array of strings
      actions - Lengths(actions) to be taken over string values
      See Also:
    • isFloat

      public static boolean isFloat(String value)
      Checks whether specified value convertable to float
      Parameters:
      value -
      Returns:
      True if value converts and False otherwise
    • toCsv

      public static String toCsv(List<?> strings)
      Convert List of strings to comma-separated string
      Parameters:
      strings - Original strings container
      Returns:
      Comma-separated list of values taken from original container
    • toCsv

      public static String toCsv(String[] array)
      Convert array of strings to comma-separated string
      Parameters:
      array - Original strings container
      Returns:
      Comma-separated list of values
    • toCsv

      public static String toCsv(Object[] array)
      Convert array of objects to comma-separated string using the toString() method to retrieve the value for each entry.
      Parameters:
      array - Original strings container
      Returns:
      Comma-separated list of values
    • toCsv

      public static String toCsv(int[] array)
      Convert array of int to comma-separated string
      Parameters:
      array - Original int container
      Returns:
      Comma-separated list of values
    • toCsv

      public static String toCsv(short[] array)
      Convert array of short to comma-separated string
      Parameters:
      array - Original short container
      Returns:
      Comma-separated list of values
    • toCsv

      public static String toCsv(long[] array)
      Convert array of long to comma-separated string
      Parameters:
      array - Original long container
      Returns:
      Comma-separated list of values
    • toCsv

      public static String toCsv(boolean[] array)
      Convert array of boolean to comma-separated string
      Parameters:
      array - Original boolean container
      Returns:
      Comma-separated list of values
    • toCsv

      public static String toCsv(float[] array)
      Convert array of float to comma-separated string
      Parameters:
      array - Original float container
      Returns:
      Comma-separated list of values
    • toCsv

      public static String toCsv(double[] array)
      Convert array of double to comma-separated string
      Parameters:
      array - Original double container
      Returns:
      Comma-separated list of values
    • toCsv

      public static String toCsv(byte[] array)
      Convert array of byte to comma-separated string
      Parameters:
      array - Original byte container
      Returns:
      Comma-separated list of values
    • getIntArrayFromCsv

      public static int[] getIntArrayFromCsv(String data)
      Parses csv string and returns array of ints as a result of parsing. Of course this appliable only when you do know that string contains integers
      Parameters:
      data - Original data to parse
      Returns:
      array of integers
    • getShortArrayFromCsv

      public static short[] getShortArrayFromCsv(String data)
      Parses csv string and returns array of short as a result of parsing. Of course this appliable only when you do know that string contains shorts
      Parameters:
      data - Original data to parse
      Returns:
      array of integers
    • getLongArrayFromCsv

      public static long[] getLongArrayFromCsv(String data)
      Parses csv string and returns array of long as a result of parsing. Of course this appliable only when you do know that string contains longs
      Parameters:
      data - Original data to parse
      Returns:
      array of integers
    • getFloatArrayFromCsv

      public static float[] getFloatArrayFromCsv(String data)
      Parses csv string and returns array of float as a result of parsing. Of course this appliable only when you do know that string contains floats
      Parameters:
      data - Original data to parse
      Returns:
      array of integers
    • getDoubleArrayFromCsv

      public static double[] getDoubleArrayFromCsv(String data)
      Parses csv string and returns array of double as a result of parsing. Of course this appliable only when you do know that string contains doubles
      Parameters:
      data - Original data to parse
      Returns:
      array of integers
    • getBooleanArrayFromCsv

      public static boolean[] getBooleanArrayFromCsv(String data)
      Parses csv string and returns array of boolean as a result of parsing. Of course this appliable only when you do know that string contains booleans
      Parameters:
      data - Original data to parse
      Returns:
      array of integers
    • getByteArrayFromCsv

      public static byte[] getByteArrayFromCsv(String data)
      Parses csv string and returns array of boolean as a result of parsing. Of course this appliable only when you do know that string contains booleans
      Parameters:
      data - Original data to parse
      Returns:
      array of integers
    • csvToSet

      public static Set<String> csvToSet(String csvLine)
      Convert comma-separated line to Set of strings. This is especially useful when you do know that line can convert duplicates and you don't want to deal with them.
      Parameters:
      csvLine - Original comma-separated line
      Returns:
      Set of values represented in the comma-separated line
    • concat

      public static String concat(String s1, String s2)
      Fast 2 string concatenation using StringBuffer.
      Parameters:
      s1 - source string #1
      s2 - source string #2
      Returns:
      2 strings concatenated
    • concat

      public static String concat(String s1, String s2, String s3)
      Fast 3 strings concatenation using StringBuffer
      Parameters:
      s1 - source string #1
      s2 - source string #2
      s3 - source string #3
      Returns:
      3 strings concatenated
    • concat

      public static String concat(String s1, String s2, String s3, String s4)
      Fast 4 string concatenation using StringBuffer
      Parameters:
      s1 - source string #1
      s2 - source string #2
      s3 - source string #3
      s4 - source string #4
      Returns:
      4 strings concatenated
    • fastParseLong

      public static long fastParseLong(String str) throws NumberFormatException
      Fast implementation of Long.parseLong(java.lang.String, int)
      • It assumes that it parses decimal radix number
      • It doesn't not check Long constraints
      • It doesn't handle unicode string
      Parameters:
      str - string to convert
      Returns:
      long value obtained as a result of string conversion
      Throws:
      NumberFormatException
    • getDelimitedList

      public static ArrayList<String> getDelimitedList(String value, String delims, boolean includeDelim)
      Get ArrayList of tokens from delimited original string
      Parameters:
      value - Original string value
      delims - Delimiters used to make tokens
      Returns:
      list of tokens produced as a result of string parsing
    • getDelimitedList

      public static ArrayList<String> getDelimitedList(String value, String delims)
      Get ArrayList of tokens from delimited original string
      Parameters:
      value - Original string value
      delims - Delimiters used to make tokens
      Returns:
      list of tokens produced as a result of string parsing
    • charStr

      public static String charStr(char character, int count)
      Creates a string consisting of the given character
      Parameters:
      character - original character
      count - length of the string to construct
      Returns:
      String containing count characters
    • tabStr

      public static String tabStr(int count)
      Return string containing the specified quantity of '\t' character
      Parameters:
      count - Quantity of tabs you want to recieve
      Returns:
      String containing the given quantity of TAB characters
      See Also:
    • isEmpty

      public static boolean isEmpty(String s1, String s2)
      Checks whether one of the 2 strings is empty
      Parameters:
      s1 - source string #1
      s2 - source string #2
      Returns:
      True, if one of the strings are empty, False - otherwise
    • notEmpty

      public static boolean notEmpty(String s1, String s2)
      Checks that 2 strings are not empty
      Parameters:
      s1 - string to check #1
      s2 - string to check #2
      Returns:
      True, if both strings are not empty, False - otherwise
    • notNulls

      public static boolean notNulls(String value1, String value2)
      Checks that 2 strings are not nulls
      Parameters:
      value1 - source string #1
      value2 - source string #2
      Returns:
      True, if both strings are not nulls, False - otherwise
    • removeChars

      public static String removeChars(String orig, String chars)
      Replaces all chars with the replacement char
      Parameters:
      orig - Original string
      chars - Chars to remove
      Returns:
      Original string with all specified characters removed
    • isFormatCharsOnly

      public static boolean isFormatCharsOnly(String value)
      Verifies that string contains only formatting characters
      Parameters:
      value - Original string
      Returns:
      True, if string contains only '\t\n' characters, False otherwise
    • replaceParams

      public static String replaceParams(String source, String[] params)
      Replace placeholders, or parameters, in a string that are of the format %[number].
         Example: Calling on string "Error locating resource %0 for user %1" with array {"root", "admin"}
                  would result in "Error locating resource root for user admin"
       
      Parameters:
      source - a string with parameters, starting with 0
      params - the values for the parameters, the index corresponding to the parameter value + 1
      Returns:
      the string with the values in place
    • trimString

      public static String trimString(String s, String charsToTrim)
      Trims specified characters from the beginning and end of the string
      Parameters:
      s -
      charsToTrim -
    • capitalizeName

      public static String capitalizeName(String name)
      Capitalizes name string
    • humanizeName

      public static String humanizeName(String name)
      Converts identifiers like "myJavaCompliantName123" into "My Java Compliant Name 123"
      Parameters:
      name - the value to humanize
      Returns:
      the humanized value
    • lowerCaseFirstChar

      public static String lowerCaseFirstChar(String s)
      Lower cases first character of a string
      Parameters:
      s - null or String
      Returns:
      s with lowercase first character
    • upperCaseFirstChar

      public static String upperCaseFirstChar(String s)
      Capilizes first character of a string
      Parameters:
      s - null or String
      Returns:
      s with a capital first character
    • getStackTrace

      public static String getStackTrace(Throwable t)
      Utility function to recieve exception stack trace as a string
      Parameters:
      t - Throwable to work with
      Returns:
      Throwable stack trace as a String
    • loadStringfromStream

      public static String loadStringfromStream(InputStream input) throws IOException
      Loads and return string from an InputStream
      Returns:
      All contents of the file as one string
      Throws:
      IOException - in case of any I/O error
    • loadStringFromReader

      public static String loadStringFromReader(Reader reader) throws IOException
      Loads and return string from a reader. HACK is used to speed-up string getting from StringAccessReader
      Parameters:
      reader - Source reader
      Returns:
      String contents of the reader
      Throws:
      IOException
      See Also:
      • StringAccessReader
    • padLeft

      public static String padLeft(String string, char padChar, int length)
    • isEmptyString

      public static boolean isEmptyString(Object obj)
      Verifies whether passed string is a String or String[] and whether empty or not.
      Parameters:
      str - Source string to analyze
      Returns:
      True, if string is empty, False - otherwise
    • getFullStackTrace

      public static String getFullStackTrace(Throwable t)
      Utility function to construct full exception stack trace information. This is useful when you are dealing with nested exceptions what can contain many levels of stack traces inside
      Parameters:
      t - Throwable to analyze
      Returns:
      String stack trace representation
    • checkValueForControlCharacters

      public static void checkValueForControlCharacters(String key, String value)