Class StringUtil

java.lang.Object
ubic.basecode.util.StringUtil

public class StringUtil extends Object
Author:
pavlidis
  • Constructor Details

    • StringUtil

      public StringUtil()
  • Method Details

    • append

      public static String append(String appendee, String appendant, String separator)
      Parameters:
      appendee - The string to be added to
      appendant - The string to add to the end of the appendee
      separator - The string to put between the joined strings, if necessary.
      Returns:
      appendee + separator + separator unless appendee is empty, in which case the appendant is returned.
    • commonPrefix

      public static String commonPrefix(Collection<String> strings)
      Given a set of strings, identify any prefix they have in common.
      Parameters:
      strings -
      Returns:
      the common prefix, null if there isn't one.
    • commonSuffix

      public static String commonSuffix(Collection<String> strings)
      Given a set of strings, identify any suffix they have in common.
      Parameters:
      strings -
      Returns:
      the commons suffix, null if there isn't one.
    • containsValidCharacter

      public static boolean containsValidCharacter(String s)
      Checks a string to find "strange" character, used by phenocarta to check evidence description
      Parameters:
      the - string to check
      Returns:
      return false if something strange was found
    • csvSplit

      public static String[] csvSplit(String line)
      Parameters:
      line -
      Returns:
    • cvs2tsv

      public static String cvs2tsv(String line)
      Made by Nicolas
      Parameters:
      a - line in a file cvs format
      Returns:
      the same line but in tsv format
    • isLatinLetter

      public static boolean isLatinLetter(char c)
    • makeValidForR

      public static String makeValidForR(String s)
      Deprecated.
      Mimics the make.names method in R (character.c) to make valid variables names; we use this for column headers in some output files.

      This was modified in 1.1.26 to match the behavior of R more closely, if not exactly.

      Parameters:
      s - a string to be made valid for R
      Returns:
      modified string
    • makeValidForR

      @Deprecated public static String[] makeValidForR(String[] strings)
      Deprecated.
      Mimics the make.names method in R when using with a vector of strings and the unique argument set to TRUE.
    • makeNames

      public static String[] makeNames(String[] strings, boolean unique)
      Mimics the make.names method in R.
      Parameters:
      strings - a list of strings to be made valid for R
      unique - if true, will ensure that the names are unique by appending a number to duplicates as per makeUnique(String[])
    • makeNames

      public static String makeNames(String s)
      Mimics the make.names method in R for a single string.
    • makeUnique

      public static String[] makeUnique(String[] strings)
      Mimics the make.unique method in R.

      Duplicated values in the input array will be suffixed with a dot and a number, starting from 1.

    • twoStringHashKey

      public static Long twoStringHashKey(String stringi, String stringj)
      Parameters:
      stringi -
      stringj -
      Returns: