Class StringUtil
java.lang.Object
ubic.gemma.core.util.StringUtil
String helpers (R-style name munging, common prefix/suffix, CSV split, etc.).
Ported in-tree from ubic.basecode.util.StringUtil as part of the Phase 3
baseCode util retirement (see BASECODE_DEP_AUDIT.md). Methods not called
by Gemma have been dropped: containsValidCharacter, cvs2tsv,
isLatinLetter, makeValidForR, twoStringHashKey. The
single-arg legacy makeValidForR(String) is gone; callers use
makeNames(String) directly.
Distinct from StringUtils (plural) which extends
StringUtils.
- Author:
- pavlidis
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic StringcommonPrefix(Collection<String> strings) Given a set of strings, identify any prefix they have in common.static StringcommonSuffix(Collection<String> strings) Given a set of strings, identify any suffix they have in common.static String[]Split a single CSV-formatted line into fields.static StringMimics themake.namesmethod in R for a single string.static String[]Mimics themake.namesmethod in R.static String[]makeUnique(String[] strings) Mimics themake.uniquemethod in R.
-
Constructor Details
-
StringUtil
public StringUtil()
-
-
Method Details
-
append
- Parameters:
appendee- The string to be added toappendant- The string to add to the end of the appendeeseparator- The string to put between the joined strings, if necessary.- Returns:
- appendee + separator + appendant unless appendee is empty, in which case the appendant is returned.
-
commonPrefix
Given a set of strings, identify any prefix they have in common.- Returns:
- the common prefix, null if there isn't one.
-
commonSuffix
Given a set of strings, identify any suffix they have in common.- Returns:
- the common suffix, null if there isn't one.
-
csvSplit
-
makeNames
Mimics themake.namesmethod in R.- Parameters:
strings- a list of strings to be made valid for Runique- if true, will ensure that the names are unique by appending a number to duplicates as permakeUnique(String[])
-
makeNames
-
makeUnique
-