|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||
java.lang.Object | +--Utility
Class with assorted utility functions. It's declared as abstract to ensure that nobody confusedly tries to instantiate any objects in it.
| Field Summary | |
(package private) static javax.swing.JFileChooser |
fc
We keep a file chooser sitting around to preserve the user's preferences. |
(package private) static java.awt.Frame |
myFrame
frame to be used as a default parent where needed. |
| Constructor Summary | |
Utility()
|
|
| Method Summary | |
static void |
fileSave(java.lang.String defaultFileName,
java.lang.String contents)
Save a string into a file. |
(package private) static boolean |
processFile(java.lang.String fileName,
LineProcessor lp)
Process a file, with callbacks for each line. |
(package private) static java.lang.String |
removeTrailing(java.lang.String longString,
java.lang.String trash)
Remove trailing characters from a string. |
(package private) static java.lang.String |
replace(java.lang.String longString,
java.lang.String delimiter,
java.lang.String replaceString)
Within a long string, replace a single occurence of one substring with another. |
static void |
setClipboard(java.lang.String s)
Put a string on the system clipboard |
static void |
setFrame(java.awt.Frame f)
Set the default parent frame for popup windows. |
(package private) static java.lang.String |
stringPiece(java.lang.String longString,
java.lang.String delimiter,
int piece)
Extract a delimited substring from a string. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
static javax.swing.JFileChooser fc
static java.awt.Frame myFrame
setFrame(java.awt.Frame)| Constructor Detail |
public Utility()
| Method Detail |
public static void fileSave(java.lang.String defaultFileName,
java.lang.String contents)
defaultFileName - file name intended to be could be
displayed to the user as a default. Not used in this
implementation due to lack of time and know-how.contents - a string to be written. If the string
is delimited by newlines, each line will be written
separately. This means that the file will contain the
proper line breaks for the local operating system.
static boolean processFile(java.lang.String fileName,
LineProcessor lp)
fileName - the name of the file to be processedlp - an object with methods to handle lines and exceptionstrue if the file was successfully processed;
false if either there was an IO exception or the
line processor indicated that it could not process a line
static java.lang.String removeTrailing(java.lang.String longString,
java.lang.String trash)
longString - the string on which we're operatingtrash - a collection of characters to be removed from the endtrash.
static java.lang.String replace(java.lang.String longString,
java.lang.String delimiter,
java.lang.String replaceString)
longString - the string on which we're operatingdelimiter - the substring to be replacedreplaceString - the new substringpublic static void setClipboard(java.lang.String s)
s - the string to be placed on the clipboardpublic static void setFrame(java.awt.Frame f)
JFileChooser.showSaveDialog
to create windows require (and others prefer) a parent frame to be
passed in. This call sets a private variable to be used as
the parent in subsequent Swing calls.
static java.lang.String stringPiece(java.lang.String longString,
java.lang.String delimiter,
int piece)
StringTokenizer. My background always
had this available, so I've come to think this way.longString - the original string, containing delimitersdelimiter - character(s) which break up the original
string into pieces. Unlike StringTokenizer, if
this is longer than one character, the entire sequence is
treated as a single delimiter, rather than having the string
represent a collection of one-character alternative delimiters.piece - which piece is wanted, counting from 1piece is less than 1 or greater than the
number of pieces in the original string, an empty string is
returned.
|
||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||