megamek.common.util
Class StringUtil

java.lang.Object
  extended by megamek.common.util.StringUtil

public class StringUtil
extends java.lang.Object


Constructor Summary
StringUtil()
           
 
Method Summary
static java.lang.String addDateTimeStamp(java.lang.String filename)
          Inserts a date/time stamp into the given filename string just before the last period.
static java.lang.String makeLength(int s, int n)
           
static java.lang.String makeLength(java.lang.String s, int n)
           
static java.lang.String makeLength(java.lang.String s, int n, boolean bRightJustify)
          A utility for padding out a string with spaces.
static boolean parseBoolean(java.lang.String input)
          Determine the boolean value of the given String.
static java.util.Vector<java.lang.String> splitString(java.lang.String s, java.lang.String divider)
           
static java.util.Comparator<java.lang.String> stringComparator()
           
 
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

splitString

public static java.util.Vector<java.lang.String> splitString(java.lang.String s,
                                                             java.lang.String divider)

stringComparator

public static java.util.Comparator<java.lang.String> stringComparator()

parseBoolean

public static boolean parseBoolean(java.lang.String input)
Determine the boolean value of the given String. Treat all null values as false. The default is false. This ensures the String will always be parsed against the English "true"

Parameters:
input - - the String to be evaluated. This value may be null.
Returns:
The boolean equivalent of the input.

makeLength

public static java.lang.String makeLength(java.lang.String s,
                                          int n)

makeLength

public static java.lang.String makeLength(int s,
                                          int n)

makeLength

public static java.lang.String makeLength(java.lang.String s,
                                          int n,
                                          boolean bRightJustify)
A utility for padding out a string with spaces.

Parameters:
s - the string to pad
n - the desired length of the resultant string
bRightJustify - true if the string should be right justified

addDateTimeStamp

public static java.lang.String addDateTimeStamp(java.lang.String filename)
Inserts a date/time stamp into the given filename string just before the last period. If there is no period in the filename, the stamp is added to the end. The format of the stamp is dictated by the client option "StampFormat", which must use the same formatting as Java's SimpleDateFormat class.

Parameters:
filename - the String containing the filename (with extension)
Returns:
the filname with date/time stamp added