mark.core.text
Class Util

java.lang.Object
  |
  +--mark.core.text.Util

public class Util
extends java.lang.Object

Util is a class that contains a number of simple static utility methods.


Constructor Summary
Util()
           
 
Method Summary
static java.lang.String format(double d)
          Converts a double to a string, formatted with six digits after the decimal point.
static java.lang.String format(int n, int numDigits)
          Converts an integer to a string, formatted to fill at least the given number of digits.
static java.lang.String join(java.lang.String delimiter, java.util.Collection comps)
          Joins strings into a single string based on a delimeter String.
static java.lang.String replace(java.lang.String s, java.lang.String replace, java.lang.String with)
          Replaces every occurrence of one substring with another.
static java.lang.String shorten(double d)
          Converts a double to a string.
static java.util.LinkedList split(java.lang.String delim, java.lang.String str)
          Splits a string into compoments based on a separator String.
static java.util.LinkedList toCollection(java.lang.String[] args)
          Converts an array of Strings to a LinkedList of strings.
static java.lang.String[] toSortedStringArray(java.util.Collection c)
          Calls toStringArray and then sorts the result.
static java.lang.String[] toStringArray(java.util.Collection c)
          Converts a collection of Strings into an array of strings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

split

public static java.util.LinkedList split(java.lang.String delim,
                                         java.lang.String str)
Splits a string into compoments based on a separator String. Does what Perl's split function does, except that we don't have regular expressions built into Java.

Parameters:
delim - the delimiter.
str - the String.
Returns:
the components of the string.

join

public static java.lang.String join(java.lang.String delimiter,
                                    java.util.Collection comps)
Joins strings into a single string based on a delimeter String. Does what Perl's join function does.

Parameters:
comps - a Collection containing the Strings to join.
Returns:
the joined string.

format

public static java.lang.String format(double d)
Converts a double to a string, formatted with six digits after the decimal point.

Parameters:
d - the double.
Returns:
the formatted string representation of d.

shorten

public static java.lang.String shorten(double d)
Converts a double to a string. Removes the fractional part if it is zero.

Parameters:
d - the double.
Returns:
the formatted string representation of d.

format

public static java.lang.String format(int n,
                                      int numDigits)
Converts an integer to a string, formatted to fill at least the given number of digits.

Parameters:
n - the int.
numDigits - the number of digits.
Returns:
the string.

toCollection

public static java.util.LinkedList toCollection(java.lang.String[] args)
Converts an array of Strings to a LinkedList of strings.

Parameters:
args - the array of Strings.
Returns:
the LinkedList.

toStringArray

public static java.lang.String[] toStringArray(java.util.Collection c)
Converts a collection of Strings into an array of strings.

Returns:
the array.

toSortedStringArray

public static java.lang.String[] toSortedStringArray(java.util.Collection c)
Calls toStringArray and then sorts the result.

Returns:
the sorted result.

replace

public static java.lang.String replace(java.lang.String s,
                                       java.lang.String replace,
                                       java.lang.String with)
Replaces every occurrence of one substring with another.

Parameters:
s - the string to replace.
replace - replace this string.
with - with this string.