uk.ac.cam.ch.wwmm.opsin
Class StringTools

java.lang.Object
  extended by uk.ac.cam.ch.wwmm.opsin.StringTools

public final class StringTools
extends java.lang.Object

Static routines for string manipulation. This is a specially tailored version of StringTools as found in OSCAR for use in OPSIN


Constructor Summary
StringTools()
           
 
Method Summary
static java.util.List<java.lang.String> arrayToList(java.lang.String[] array)
          Converts a string array to an ArrayList.
static java.lang.String arrayToString(java.lang.String[] stringArray, java.lang.String separator)
          Joins an array of strings into a single string.
static java.lang.String charListToString(java.util.List<java.lang.Character> l)
          Converts a list of characters into a string.
static java.lang.String convertNonAsciiAndNormaliseRepresentation(java.lang.String s)
          Converts a unicode string into ISO-8859-1, converting greek letters to their names, and difficult characters to underscore.
static int countTerminalPrimes(java.lang.String locantText)
          Counts the number of primes at the end of a locant
static boolean endsWithCaseInsensitive(java.lang.String str, java.lang.String suffix)
          Tests if this string ends with the specified suffix ignoring case.
static java.lang.String multiplyString(java.lang.String s, int n)
          Produce repetitions of a string.
static java.lang.String removeDashIfPresent(java.lang.String locantText)
          If a dash is the last character it is removed
static java.lang.String stringListToString(java.util.List<java.lang.String> l, java.lang.String separator)
          Converts a list of strings into a single string delimited by the given separator
static java.util.List<java.lang.Character> stringToList(java.lang.String s)
          Converts a string to a list of characters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringTools

public StringTools()
Method Detail

charListToString

public static java.lang.String charListToString(java.util.List<java.lang.Character> l)
Converts a list of characters into a string.

Parameters:
l - A list of characters.
Returns:
The corresponding string.

stringListToString

public static java.lang.String stringListToString(java.util.List<java.lang.String> l,
                                                  java.lang.String separator)
Converts a list of strings into a single string delimited by the given separator

Parameters:
l - A list of strings.
Returns:
The corresponding string.

stringToList

public static java.util.List<java.lang.Character> stringToList(java.lang.String s)
Converts a string to a list of characters.

Parameters:
s - A string.
Returns:
The corresponding list of characters.

multiplyString

public static java.lang.String multiplyString(java.lang.String s,
                                              int n)
Produce repetitions of a string. Eg. HelloWorld * 2 = HelloWorldHelloWorld.

Parameters:
s - The string to multiply.
n - The number of times to multiply it.
Returns:
The multiplied string.

arrayToString

public static java.lang.String arrayToString(java.lang.String[] stringArray,
                                             java.lang.String separator)
Joins an array of strings into a single string.

Parameters:
stringArray - The strings to join together.
separator - The separator to use.
Returns:
The resulting string.

convertNonAsciiAndNormaliseRepresentation

public static java.lang.String convertNonAsciiAndNormaliseRepresentation(java.lang.String s)
                                                                  throws uk.ac.cam.ch.wwmm.opsin.PreProcessingException
Converts a unicode string into ISO-8859-1, converting greek letters to their names, and difficult characters to underscore.

Parameters:
s - The string to convert.
Returns:
The converted string.
Throws:
PreProcessingException

arrayToList

public static java.util.List<java.lang.String> arrayToList(java.lang.String[] array)
Converts a string array to an ArrayList.

Parameters:
array - The array.
Returns:
The ArrayList.

removeDashIfPresent

public static java.lang.String removeDashIfPresent(java.lang.String locantText)
If a dash is the last character it is removed

Parameters:
locantText -
Returns:

countTerminalPrimes

public static int countTerminalPrimes(java.lang.String locantText)
Counts the number of primes at the end of a locant

Parameters:
locantText -
Returns:

endsWithCaseInsensitive

public static boolean endsWithCaseInsensitive(java.lang.String str,
                                              java.lang.String suffix)
Tests if this string ends with the specified suffix ignoring case.

Parameters:
str -
suffix -
Returns: