public final class Str
extends java.lang.Object
The latter, I find really annoying! The routines here therefore colate a number of frequently performed procedures and provide shortcuts to their operation.
Also, there are routines for counting the line numbers and finding and replacing etc.Constructor and Description |
---|
Str() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
copy(java.lang.String s)
Copies a String, not by reference
|
static int |
howMany()
gets number of replacings made by the replaceAll function.
|
static java.lang.String |
insertString(java.lang.String theString,
int pos,
java.lang.String text)
Inserts a String into a given String at a given position.
|
static java.lang.String |
niceDate(java.util.Date d) |
static java.lang.String |
niceDateAndTime(java.util.Date d) |
static int |
noLineChars(java.lang.String str,
int pos)
From the specified position in the String this function returns the number of characters excluding line feeds
for this position.
|
static void |
printHashtable(java.util.Hashtable v,
java.io.PrintWriter pw)
For printing out the types and associated colours to the user configuration file.
|
static void |
printTreeMap(java.util.TreeMap v,
java.io.PrintWriter pw)
For printing out the types and associated colours to the user configuration file.
|
static void |
printVector(java.util.Vector v,
java.io.PrintWriter pw)
Prints a vector one element after another with a new line between each element.
|
java.lang.String |
removeSubstring(java.lang.String theString,
int from,
int to)
Removes a substring from the given String and returns a String consisting of the remaining parts concatenated.
|
static java.lang.String |
replaceAll(java.lang.String theString,
java.lang.String text,
java.lang.String newText)
Replace all occurances of text with newText from theString.
|
static java.lang.String |
replaceNext(java.lang.String theString,
int pos,
java.lang.String text,
java.lang.String newText)
Starting at the given position, this method finds the next occurence of the given string text from the
string theString and replaces it with the newText.
|
static java.lang.String |
replaceNext(java.lang.String theString,
java.lang.String text,
java.lang.String newText)
Finds the next occurence of the given string text from the string theString and replaces it with
the newText.
|
static StringVector |
splitText(java.lang.String text)
This function splits the text into a vector of lines contained within that text i.e.
|
static StringVector |
splitTextBySpace(java.lang.String text)
Splits the text by items separated by white space
|
static boolean |
strToBoolean(java.lang.String str)
Attempts to convert a String to a boolean
|
static byte |
strToByte(java.lang.String str)
Attempts to convert a String to a byte
|
static double |
strToDouble(java.lang.String str)
Attempts to convert a String to a double
|
static float |
strToFloat(java.lang.String str)
Attempts to convert a String to a float
|
static int |
strToInt(java.lang.String str)
Attempts to convert a String to an int
|
static long |
strToLong(java.lang.String str)
Attempts to convert a String to a long
|
static short |
strToShort(java.lang.String str)
Attempts to convert a String to a short
|
public static java.lang.String copy(java.lang.String s)
public static float strToFloat(java.lang.String str) throws java.lang.NumberFormatException, java.lang.NullPointerException
java.lang.NumberFormatException
java.lang.NullPointerException
public static double strToDouble(java.lang.String str) throws java.lang.NumberFormatException, java.lang.NullPointerException
java.lang.NumberFormatException
java.lang.NullPointerException
public static int strToInt(java.lang.String str) throws java.lang.NumberFormatException, java.lang.NullPointerException
java.lang.NumberFormatException
java.lang.NullPointerException
public static short strToShort(java.lang.String str) throws java.lang.NumberFormatException, java.lang.NullPointerException
java.lang.NumberFormatException
java.lang.NullPointerException
public static long strToLong(java.lang.String str) throws java.lang.NumberFormatException, java.lang.NullPointerException
java.lang.NumberFormatException
java.lang.NullPointerException
public static byte strToByte(java.lang.String str) throws java.lang.NumberFormatException, java.lang.NullPointerException
java.lang.NumberFormatException
java.lang.NullPointerException
public static boolean strToBoolean(java.lang.String str) throws java.lang.NumberFormatException, java.lang.NullPointerException
java.lang.NumberFormatException
java.lang.NullPointerException
public static final java.lang.String niceDate(java.util.Date d)
public static final java.lang.String niceDateAndTime(java.util.Date d)
public static java.lang.String replaceNext(java.lang.String theString, java.lang.String text, java.lang.String newText)
theString
- the String to scantext
- the text to find within theStringnewText
- the String to replace text withpublic static java.lang.String replaceNext(java.lang.String theString, int pos, java.lang.String text, java.lang.String newText)
theString
- the String to scanpos
- the starting index within the given stringtext
- the text to find within theStringnewText
- the String to replace text withpublic static java.lang.String insertString(java.lang.String theString, int pos, java.lang.String text)
theString
- The String to be modifiedpos
- The index at which the insertion is to be madetext
- The insertion Stringpublic java.lang.String removeSubstring(java.lang.String theString, int from, int to)
theString
- The String to be modifiedfrom
- The index of the first character to be removedto
- The index of the first character that remains after the removed Stringpublic static java.lang.String replaceAll(java.lang.String theString, java.lang.String text, java.lang.String newText)
theString
- the string to scantext
- the text to find within theStringnewText
- the string to replace text withpublic static int noLineChars(java.lang.String str, int pos)
public static int howMany()
public static StringVector splitTextBySpace(java.lang.String text)
public static StringVector splitText(java.lang.String text)
public static void printVector(java.util.Vector v, java.io.PrintWriter pw)
public static void printHashtable(java.util.Hashtable v, java.io.PrintWriter pw)
format
public static void printTreeMap(java.util.TreeMap v, java.io.PrintWriter pw)
format