jsky.util
Class StringUtil

java.lang.Object
  extended by jsky.util.StringUtil

public class StringUtil
extends java.lang.Object

Contains static String utility methods.


Constructor Summary
StringUtil()
           
 
Method Summary
static boolean arrayContains(java.lang.String[] ar, java.lang.String s)
          Return true if the given array contains the given String
static java.lang.String combine(java.lang.String[] ar, java.lang.String sep)
          Combine the given array of strings to a single string and return the result.
static boolean equals(java.lang.String s1, java.lang.String s2)
          Return true if the two strings are equal (like String.equals(), but allowing null values for both operands).
static void main(java.lang.String[] args)
          test main
static boolean match(java.lang.String pattern, java.lang.String string)
          Checks whether a string matches a given wildcard pattern.
static java.lang.String pad(java.lang.String s, int length, boolean leftJustify)
          Pad the given string to the given length with blanks on the left or right, depending on the value of the leftJustify argument.
static java.lang.String replace(java.lang.String source, java.lang.String target, java.lang.String replacement)
          Replace all occurances of the given target string with the given replacement string in the source string.
static java.lang.String[] split(java.lang.String s, int sep)
          Split the string s at the given separator char, if found, and return an array containing the two resulting strings, or null if the separator char was not found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringUtil

public StringUtil()
Method Detail

replace

public static java.lang.String replace(java.lang.String source,
                                       java.lang.String target,
                                       java.lang.String replacement)
Replace all occurances of the given target string with the given replacement string in the source string.

Parameters:
source - source string to be searched
target - the target string to replace
replacement - the value to replace the target string with
Returns:
a new string with the target string replaced with the replacement string.

split

public static java.lang.String[] split(java.lang.String s,
                                       int sep)
Split the string s at the given separator char, if found, and return an array containing the two resulting strings, or null if the separator char was not found.


combine

public static java.lang.String combine(java.lang.String[] ar,
                                       java.lang.String sep)
Combine the given array of strings to a single string and return the result.

Parameters:
ar - an array of Strings, one element for each Tcl list item
sep - put this between the strings
Returns:
a String in the format "s1SEPs2SEP..."

equals

public static boolean equals(java.lang.String s1,
                             java.lang.String s2)
Return true if the two strings are equal (like String.equals(), but allowing null values for both operands).


match

public static boolean match(java.lang.String pattern,
                            java.lang.String string)
Checks whether a string matches a given wildcard pattern. Only does ? and * (or '%'), and multiple patterns separated by |. (Taken from http://www.acme.com/java/software/Acme.Utils.html).


pad

public static java.lang.String pad(java.lang.String s,
                                   int length,
                                   boolean leftJustify)
Pad the given string to the given length with blanks on the left or right, depending on the value of the leftJustify argument.

Parameters:
s - the source string
length - fill the string with blanks if it is less than this length
leftJustify - if true, add blanks after the s, otherwise before

arrayContains

public static boolean arrayContains(java.lang.String[] ar,
                                    java.lang.String s)
Return true if the given array contains the given String


main

public static void main(java.lang.String[] args)
test main