Class StringFunctions

java.lang.Object
org.lifstools.jgoslin.domain.StringFunctions

public final class StringFunctions extends Object
Utility methods for strings and grammars.
Author:
Dominik Kopczynski, Nils Hoffmann
  • Field Details

    • DEFAULT_QUOTE

      public static char DEFAULT_QUOTE
    • DEFAULT_SPLIT

      public static char DEFAULT_SPLIT
  • Method Details

    • strip

      public static String strip(String s, char c)
    • splitString

      public static ArrayList<String> splitString(String text)
      Split the provided text at DEFAULT_SPLIT as separator, using DEFAULT_QUOTE as the default quotation char.
      Parameters:
      text - the text to split
      Returns:
      the split string as a list
    • splitString

      public static ArrayList<String> splitString(String text, char separator, char quote)
      Split the provided text at separator, respecting the quote char to not split in between quoted parts.
      Parameters:
      text - the text to split
      separator - the separator to split at
      quote - the quotation character
      Returns:
      the split string as a list
    • splitString

      public static ArrayList<String> splitString(String text, char separator, char quote, boolean withEmpty)
      Split the provided text at separator, respecting the quote char to not split in between quoted parts. Optionally allow empty / whitespace at the end.
      Parameters:
      text - the text to split
      separator - the separator to split at
      quote - the quotation character
      withEmpty - if true, allow empty parts
      Returns:
      the split string as a list
    • getResourceAsStringList

      public static List<String> getResourceAsStringList(org.springframework.core.io.Resource resource)
      Read the provided resource and split it at default new line characters into a list for each line.
      Parameters:
      resource - the resource to read
      Returns:
      a list of line strings
    • getResourceAsStringList

      public static List<String> getResourceAsStringList(String resourcePath)
      Read the provided resource path, which is converted to a ClassPathResource and split it at default new line characters into a list for each line.
      Parameters:
      resourcePath - the resource path to read from
      Returns:
      a list of line strings
    • getResourceAsString

      public static String getResourceAsString(org.springframework.core.io.Resource resource)
      Read the provided resource and return it as a string.
      Parameters:
      resource - the resource to read
      Returns:
      the resource content as a string
    • getResourceAsString

      public static String getResourceAsString(String resourcePath)
      Read the provided resource path and return it as a string.
      Parameters:
      resourcePath - the resource path to read from
      Returns:
      the resource content as a string