JCas
v0.3.1

cas.util
Class TextTools

java.lang.Object
  extended bycas.util.TextTools

public class TextTools
extends Object

Provides some text utilitiy functions.

Version:
1.0
Author:
Ralph Schuster

Field Summary
protected static String characters
          Character set for randiom codes.
protected static Random randomObject
          Randomizer object to create random numbers.
 
Constructor Summary
TextTools()
           
 
Method Summary
static String[] enhanceStringArray(String[] a, String s)
          Enhances a String array with another String
static String getRandomCode(int len)
          Creates an alphanumeric randomized code of the specified length.
protected  String[] getWords(String s, char[] sep)
          Retrieves words from the strings.
protected  String joinWords(String[] words)
          Joins all strings into one string separated by spaces.
protected  String joinWords(String[] words, int start)
          Joins all strings into one string separated by spaces.
protected  String joinWords(String[] words, int start, int end)
          Joins all strings into one string separated by spaces.
static long[] parseStringIntoLongArray(String s)
          Creates long[] array from comma separated list of numbers in a string.
static String replace(String s, String from, String to)
          Replaces a string portion by another string.
static String replaceOnce(String s, String from, String to)
          Replaces a string portion by another string.
protected static String replaceVariables(String s, String prefix, Properties props)
          Replaces variables in the string with the appropriate values from the Properties object.
static String[] split(String s, char pivot)
          Splits the string into portions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

randomObject

protected static Random randomObject
Randomizer object to create random numbers.


characters

protected static String characters
Character set for randiom codes.

Constructor Detail

TextTools

public TextTools()
Method Detail

split

public static String[] split(String s,
                             char pivot)
Splits the string into portions. The portions are separated by the pivot character.


replace

public static String replace(String s,
                             String from,
                             String to)
Replaces a string portion by another string.


replaceOnce

public static String replaceOnce(String s,
                                 String from,
                                 String to)
Replaces a string portion by another string.


getRandomCode

public static String getRandomCode(int len)
Creates an alphanumeric randomized code of the specified length.


parseStringIntoLongArray

public static long[] parseStringIntoLongArray(String s)
Creates long[] array from comma separated list of numbers in a string.


enhanceStringArray

public static String[] enhanceStringArray(String[] a,
                                          String s)
Enhances a String array with another String


replaceVariables

protected static String replaceVariables(String s,
                                         String prefix,
                                         Properties props)
Replaces variables in the string with the appropriate values from the Properties object.

Parameters:
s - the string
prefix - the proefix of variable names in the string
props - the values of variables
Returns:
the string with all variables replaced.

getWords

protected String[] getWords(String s,
                            char[] sep)
Retrieves words from the strings. Words are separated by characters denoted in the given array.

Parameters:
s - string to be split
sep - characters that denote separators of words
Returns:
array of words in string

joinWords

protected String joinWords(String[] words)
Joins all strings into one string separated by spaces.

Parameters:
words - the string to join
Returns:
joined string

joinWords

protected String joinWords(String[] words,
                           int start)
Joins all strings into one string separated by spaces.

Parameters:
words - the string to join
start - index of first word
Returns:
joined string

joinWords

protected String joinWords(String[] words,
                           int start,
                           int end)
Joins all strings into one string separated by spaces.

Parameters:
words - the string to join
start - index of first word
end - index of last word
Returns:
joined string

JCas
v0.3.1