org.incava.lang

Class StringExt


public class StringExt
extends java.lang.Object

Extensions to the String class.

Field Summary

static boolean
DEBUG
Set this to true for debugging output.

Method Summary

static String
join(Collection c, String str)
static String
left(String str, int n)
Returns the leftmost n characters of the string, not exceeding the length of the string.
static List
listify(String str)
Converts the (possibly quoted) string into a list, delimited by whitespace and commas..
static void
main(String[] args)
static String
pad(String str, char ch, int length)
Returns a string starting with the str parameter, with ch's following the string to a length of length.
static String
pad(String str, int length)
static String
padLeft(String str, char ch, int length)
Same as the pad method, but applies the padding to the left-hand (leading) side of the string.
static String
repeat(String str, int length)
static String
repeat(char ch, int length)
static String
right(String str, int n)
Returns the rightmost n characters of the string, not exceeding the length of the string.
static String[]
split(String str, String delim)
Returns an array of strings split at the string delimiter.
static String[]
split(String str, String delim, int max)
Returns an array of strings split at the string delimiter.
static String[]
split(String str, char delim)
Returns an array of strings split at the character delimiter.
static String[]
split(String str, char delim, int max)
Returns an array of strings split at the character delimiter.
static void
test(String str, String del)
static void
test(String str, char del)
String
toString(double n, int precision)

Field Details

DEBUG

public static boolean DEBUG
Set this to true for debugging output.

Method Details

join

public static String join(Collection c,
                          String str)

left

public static String left(String str,
                          int n)
Returns the leftmost n characters of the string, not exceeding the length of the string. Does not throw the annoying IndexOutOfBoundsException.

listify

public static List listify(String str)
Converts the (possibly quoted) string into a list, delimited by whitespace and commas..

main

public static void main(String[] args)

pad

public static String pad(String str,
                         char ch,
                         int length)
Returns a string starting with the str parameter, with ch's following the string to a length of length. Examples: pad("abcd", '*', 8) -> "abcd****" pad("abcd", '*', 3) -> "abcd"

pad

public static String pad(String str,
                         int length)

padLeft

public static String padLeft(String str,
                             char ch,
                             int length)
Same as the pad method, but applies the padding to the left-hand (leading) side of the string. Examples:
     pad("420", '*', 8) -> "*****420"
     pad("1144", '*', 3) -> "1144"
 

repeat

public static String repeat(String str,
                            int length)

repeat

public static String repeat(char ch,
                            int length)

right

public static String right(String str,
                           int n)
Returns the rightmost n characters of the string, not exceeding the length of the string. Does not throw the annoying IndexOutOfBoundsException.

split

public static String[] split(String str,
                             String delim)
Returns an array of strings split at the string delimiter.

split

public static String[] split(String str,
                             String delim,
                             int max)
Returns an array of strings split at the string delimiter.

split

public static String[] split(String str,
                             char delim)
Returns an array of strings split at the character delimiter.

split

public static String[] split(String str,
                             char delim,
                             int max)
Returns an array of strings split at the character delimiter.

test

public static void test(String str,
                        String del)

test

public static void test(String str,
                        char del)

toString

public String toString(double n,
                       int precision)