Class Strings

java.lang.Object
eu.bandm.tools.util.java.Strings

public class Strings extends Object
Utility class for string manipulation.
  • Field Details

    • linefeedPattern

      static final Pattern linefeedPattern
    • STANDARD_SUFFIX

      public static final String STANDARD_SUFFIX
      Will be appended to a truncated string.
      See Also:
  • Method Details

    • removeQuotes

      public static String removeQuotes(String in)
      Remove the first and the last character in a string. (Assuming that these are open and close quotations marks.)
    • normalizeLinefeed

      public static String normalizeLinefeed(String s)
      Replace CR and CR-LF linefeed encodings by standard Unix newline, including preceding blanks.
    • replaceLinefeedByBlank

      public static String replaceLinefeedByBlank(String s)
      Replace LF, CR and CR-LF linefeed encodings, including preceding blanks, by one single blank.
    • prefix

      public static String prefix(String s, int len, String suffix)
      Deliver the prefix of the given string of the given max length. Append the suffix if the input has been truncated.
    • prefix

      public static String prefix(String s, int len)
      Deliver the prefix of the given string of the given max length. Append the STANDARD_SUFFIX if the input has been truncated.
    • hash32

      public static String hash32(Object o)
      Delivers easily readable String representation.
    • compose

      public static String compose(String prefix, String suffix)
      Compose two Strings with "." as the standard separator.
      See Also:
      • compose(String,String,String)
    • uncapitalize

      public static String uncapitalize(String s)
      Turns the very first character to lower case.
    • capitalize

      public static String capitalize(String s)
      Turns the very first character to upper case.
    • splitByFirst

      public static String[] splitByFirst(String text)
      Takes the very first character as delimiter for splitting the rest of the string. The last character is ignored if it is the delimiter, so no empty sub-string is recognized at the end of the list. Is somehow equivalent to the xslt code splitbyfirst in doctypes/d2d_gp/libbasic.xslt.
    • iterableToString

      public static <T> String iterableToString(@Opt @Opt String openDelim, Iterable<T> elements, String separator, @Opt @Opt String closeDelim)
      Convert an Iterable into a string representation by applying Object.toString() to all elements and merging the results.
    • iterableToString

      public static <T> String iterableToString(@Opt @Opt String openDelim, Iterable<T> elements, Function<T,String> fun, String separator, @Opt @Opt String closeDelim)
      Convert an Iterable into a string representation by applying the given function to all elements and merging the results.
    • editDistance

      public static int editDistance(String s1, String s2)