com.sri.emo.wizard.creation
Class StringUtil

java.lang.Object
  extended by com.sri.emo.wizard.creation.StringUtil

public class StringUtil
extends Object

Created by Richard Vorp to include all of the utility function which deal with string manipulation or string creation


Field Summary
static int CENTER_ALIGN
           
static int LEFT_ALIGN
           
static NumberFormat nf
           
static int RIGHT_ALIGN
           
 
Method Summary
static String appendIfNotExist(String originalString, String appendString)
           
static String buffer(NumberFormat nf, double value, int length)
          inserts a double value into a buffer of size length.
static String buffer(String txt, int length)
          inserts a String txt into a buffer of size length.
static String buffer(String txt, int length, int alignment)
          inserts a String txt into a buffer of size length.
static String bufferCenterAlign(String txt, int length)
          inserts a String txt into a buffer of size length.
static String bufferNoTrim(String txt, int length)
          inserts a String txt into a buffer of size length.
static String bufferRightAlign(double value, int numFracDigits, int length)
          Makes a right aligned string buffer out of double.
static String bufferRightAlign(String txt, int length)
          inserts a String txt into a buffer of size length.
static String bufferRightAlign(String txt, String bufferTxt, int length)
           
static boolean contains(String parent, String child)
          tests to see whether the child string is contained within the parent
static int countNonEmptyStrings(String[] text)
           
static String createString(char val, int width)
           
static String createString(String val, int width)
           
static String createString(String val, int width, int height)
          Creates a string with VAL repeated WIDTH times in a line and height many lines.
static String format(double value, int maxFracDigits)
           
static String getIth(int number)
           
static String getPlural(String text, int number)
           
static int indexOf(String string, String searchCharacters)
          Finds the first index of any character (represented by searchCharacter) within the string.
static String longestString(Iterator iter)
           
static String longestString(List stringList)
          Determines he first longest from a list of strings
static String longestString(Object[] stringArray)
          Determines he first longest from a array of strings
static double[] parseDoubleTokens(String s, String delimit)
           
static int[] parseIntegerTokens(String s, String delimit)
           
static String removeOuterChar(String s, char leftOuter, char rightOuter)
           
static String removeOuterChars(String s, char leftOuter, char rightOuter)
           
static String removeQuotes(String s)
           
static String removeQuotesNoTrim(String s)
           
static String space(int times)
           
static String toString(boolean[] values)
           
static String toString(boolean[][] values)
           
static String toString(boolean[][] values, String firstDimStart, String firstDimSeparator, String firstDimEnd, String secondDimStart, String secondDimSeparator, String secondDimEnd)
           
static String toString(boolean[] values, String start, String separator, String end)
           
static String toString(Collection c)
           
static String toString(Collection c, String start, String end)
           
static String toString(Collection c, String start, String separator, String end)
           
static String toString(double[] values)
           
static String toString(double[][] values)
           
static String toString(double[][][] values)
           
static String toString(double[][][] values, String firstDimStart, String firstDimEnd, String firstDimSeparator, String secondDimStart, String secondDimSeparator, String secondDimEnd, String thirdDimStart, String thirdDimSeparator, String thirdDimEnd)
           
static String toString(double[][] values, String firstDimStart, String firstDimSeparator, String firstDimEnd, String secondDimStart, String secondDimSeparator, String secondDimEnd)
           
static String toString(double[] values, String start, String separator, String end)
           
static String toString(Enumeration enumeration)
           
static String toString(Enumeration iterator, String start, String separator, String end)
           
static String toString(int[] values)
           
static String toString(int[][] values)
           
static String toString(int[][] values, String firstDimStart, String firstDimSeparator, String firstDimEnd, String secondDimStart, String secondDimSeparator, String secondDimEnd)
           
static String toString(int[] values, String start, String separator, String end)
           
static String toString(Iterator iterator)
           
static String toString(Iterator iterator, String start, String separator, String end)
           
static String toString(Map map)
           
static String toString(Object[] values)
           
static String toString(Object[] values, String start, String separator, String end)
           
static String toString(String[] strArray)
           
static String toStringLn(Object[] values)
           
static String trim(String line, char trimCharacter)
           
static String wrap(String text, int maxLength)
           
static List wrapLines(String text, int maxLength)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LEFT_ALIGN

public static final int LEFT_ALIGN
See Also:
Constant Field Values

CENTER_ALIGN

public static final int CENTER_ALIGN
See Also:
Constant Field Values

RIGHT_ALIGN

public static final int RIGHT_ALIGN
See Also:
Constant Field Values

nf

public static NumberFormat nf
Method Detail

indexOf

public static int indexOf(String string,
                          String searchCharacters)
Finds the first index of any character (represented by searchCharacter) within the string. returns -1 if no character is found

Parameters:
string - String
searchCharacters - String
Returns:
int

toString

public static String toString(Map map)

getIth

public static String getIth(int number)

toString

public static String toString(String[] strArray)

toString

public static String toString(Collection c)

toString

public static String toString(Collection c,
                              String start,
                              String end)

toString

public static String toString(Collection c,
                              String start,
                              String separator,
                              String end)

toString

public static String toString(Enumeration enumeration)

toString

public static String toString(Enumeration iterator,
                              String start,
                              String separator,
                              String end)

toString

public static String toString(Iterator iterator)

toString

public static String toString(Iterator iterator,
                              String start,
                              String separator,
                              String end)

toString

public static String toString(Object[] values)

toStringLn

public static String toStringLn(Object[] values)

toString

public static String toString(Object[] values,
                              String start,
                              String separator,
                              String end)

toString

public static String toString(int[] values)

toString

public static String toString(int[] values,
                              String start,
                              String separator,
                              String end)

toString

public static String toString(int[][] values)

toString

public static String toString(int[][] values,
                              String firstDimStart,
                              String firstDimSeparator,
                              String firstDimEnd,
                              String secondDimStart,
                              String secondDimSeparator,
                              String secondDimEnd)

toString

public static String toString(double[] values,
                              String start,
                              String separator,
                              String end)

toString

public static String toString(boolean[] values,
                              String start,
                              String separator,
                              String end)

toString

public static String toString(double[] values)

toString

public static String toString(boolean[] values)

toString

public static String toString(double[][][] values,
                              String firstDimStart,
                              String firstDimEnd,
                              String firstDimSeparator,
                              String secondDimStart,
                              String secondDimSeparator,
                              String secondDimEnd,
                              String thirdDimStart,
                              String thirdDimSeparator,
                              String thirdDimEnd)

toString

public static String toString(double[][][] values)

toString

public static String toString(double[][] values,
                              String firstDimStart,
                              String firstDimSeparator,
                              String firstDimEnd,
                              String secondDimStart,
                              String secondDimSeparator,
                              String secondDimEnd)

toString

public static String toString(double[][] values)

toString

public static String toString(boolean[][] values)

toString

public static String toString(boolean[][] values,
                              String firstDimStart,
                              String firstDimSeparator,
                              String firstDimEnd,
                              String secondDimStart,
                              String secondDimSeparator,
                              String secondDimEnd)

contains

public static boolean contains(String parent,
                               String child)
tests to see whether the child string is contained within the parent

Parameters:
parent -
child -
Returns:

countNonEmptyStrings

public static int countNonEmptyStrings(String[] text)

createString

public static String createString(char val,
                                  int width)
Returns:
A string which represents a character duplicated n times

createString

public static String createString(String val,
                                  int width,
                                  int height)
Creates a string with VAL repeated WIDTH times in a line and height many lines. It ends with a newline character.

Parameters:
val -
width -
height -
Returns:
a string with VAL repeated WIDTH times in a line and height many lines

createString

public static String createString(String val,
                                  int width)

space

public static String space(int times)

buffer

public static String buffer(String txt,
                            int length,
                            int alignment)
inserts a String txt into a buffer of size length. if the String is too large, it will be truncated to size length. Otherwise it uses the aligment to determine how to align the txt within the buffer. Valid alignments are LEFT_ALIGN, CENTER_ALIGN, and RIGHT_ALIGN if an invalid alignment is given, LEFT_ALIGN is assumed.

Parameters:
txt - String to fit in a buffer
length -
alignment -
Returns:

wrapLines

public static List wrapLines(String text,
                             int maxLength)

wrap

public static String wrap(String text,
                          int maxLength)

buffer

public static String buffer(String txt,
                            int length)
inserts a String txt into a buffer of size length. if the String is too small, the returned string will have trailing whitespace characters after it. If the string is too big the extra characters will be cut off.

Parameters:
txt -
length -
Returns:
String of size length with txt in it.

bufferNoTrim

public static String bufferNoTrim(String txt,
                                  int length)
inserts a String txt into a buffer of size length. if the String is too small, the returned string will have trailing whitespace characters after it. If the string is too big nothing is done to shorten it. In other words, the new returned String will be exactly what was passed in.

Parameters:
txt -
length -
Returns:
String of size length with txt in it.

bufferRightAlign

public static String bufferRightAlign(String txt,
                                      int length)
inserts a String txt into a buffer of size length. if the String is too small, the returned string will have trailing whitespace characters before it.

Returns:
String of size length with txt in it.

bufferRightAlign

public static String bufferRightAlign(String txt,
                                      String bufferTxt,
                                      int length)

buffer

public static String buffer(NumberFormat nf,
                            double value,
                            int length)
inserts a double value into a buffer of size length. the value is formated according to the NumberFormat passed into it. If the value is positive a leading space is entered before it, to account for the negative values taking up that space with a - sign if the value is too small, the returned string will have trailing whitespace characters after it.

Returns:
String of size length with value in it.

bufferCenterAlign

public static String bufferCenterAlign(String txt,
                                       int length)
inserts a String txt into a buffer of size length. if the String is too small, the returned string will have trailing whitespace characters before and after it.

Returns:
String of size length with txt centered in it.

bufferRightAlign

public static String bufferRightAlign(double value,
                                      int numFracDigits,
                                      int length)
Makes a right aligned string buffer out of double. Useful for fractional numbers.

Parameters:
value - double value to be made into string
numFracDigits - number digits after fraction dot.
Returns:
string that contains value right aligned.

removeOuterChar

public static String removeOuterChar(String s,
                                     char leftOuter,
                                     char rightOuter)

removeOuterChars

public static String removeOuterChars(String s,
                                      char leftOuter,
                                      char rightOuter)

trim

public static String trim(String line,
                          char trimCharacter)

removeQuotesNoTrim

public static String removeQuotesNoTrim(String s)
Returns:
a String with any quotes removed from it

removeQuotes

public static String removeQuotes(String s)
Returns:
a String with any quotes removed from it and also trimming it afterwards.

format

public static String format(double value,
                            int maxFracDigits)

longestString

public static String longestString(List stringList)
Determines he first longest from a list of strings

Parameters:
stringList -
Returns:
the first occurence of longest string.

longestString

public static String longestString(Iterator iter)

longestString

public static String longestString(Object[] stringArray)
Determines he first longest from a array of strings

Parameters:
stringArray -
Returns:
the first occurence of longest string.

getPlural

public static String getPlural(String text,
                               int number)

parseIntegerTokens

public static int[] parseIntegerTokens(String s,
                                       String delimit)

parseDoubleTokens

public static double[] parseDoubleTokens(String s,
                                         String delimit)

appendIfNotExist

public static String appendIfNotExist(String originalString,
                                      String appendString)


Copyright © 2004-2006 Codeguild, Inc.. All Rights Reserved.