Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class tools.Tool

java.lang.Object
  |
  +--tools.Tool

public class Tool
extends java.lang.Object
The Tool class holds a selection of general purpose tools.

Version:
1.0
Author:
Copyright Neil Blue (1998)

Method Summary
static java.lang.String arrayToString(java.lang.Object[] inputArray)
          Helper function to turn an Object array into a String.
static java.lang.String getHead(java.lang.String source)
          Helper function to return the head of a String.
static java.lang.String getQuote(java.lang.String source, int number)
          Helper function to get quotes from the source String.
static java.lang.String getStdInput(boolean upper)
          Helper function to get a line from the standard input stream and return it as a String.
static java.lang.String getTail(java.lang.String source)
          Helper function to return the tail of a String.
static void pausedOutput(java.io.PrintWriter out, java.lang.String[] line, int pause, boolean lineNumber)
          Helper function to output a String array to a PrintWriter.
static java.lang.String[] stringToArray(java.lang.String inputString)
          Helper function to turns a string into an array of tokens (String[]).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Method Detail

getStdInput

public static java.lang.String getStdInput(boolean upper)
                                   throws java.io.IOException
Helper function to get a line from the standard input stream and return it as a String. The return string is set to upper case if upper is true, else there is no change.
Parameters:
upper - When true, returns the input line in upper case.
Returns:
returns The next line from the standard input as a String, else null if the input is empty.
Throws:
java.io.IOException - If System.in can not be read form.

stringToArray

public static java.lang.String[] stringToArray(java.lang.String inputString)
Helper function to turns a string into an array of tokens (String[]). The tokens are separated by white spaces, using the StringTokenizer.
Parameters:
inputString - The String to parse into tokens
Returns:
An array of String objects or null if there are no tokens in the inputString
See Also:
arrayToString(Object[] inputArray)

arrayToString

public static java.lang.String arrayToString(java.lang.Object[] inputArray)
Helper function to turn an Object array into a String. The String is created by Concatenating the Object.toString() returns separated by spaces. The general use is turn an array of words (as Strings), into a single String.
Parameters:
inputArray - The array of Objects to Concatenate.
Returns:
A String of the concatenated Object.toString() calls, else null if there are no Objects the array.
See Also:
stringToArray(String inputString)

pausedOutput

public static void pausedOutput(java.io.PrintWriter out,
                                java.lang.String[] line,
                                int pause,
                                boolean lineNumber)
                        throws java.io.IOException
Helper function to output a String array to a PrintWriter. The String array is output a String at a time, pausing after a given limit of lines and waits for or X to continue or exit. The output may also be set to include line numbers.
Parameters:
out - PrintWriter for output.
line - A String array of lines to output.
pause - The number of lines to print before pausing, or no pause if pause = 0;
lineNumber - line numbers are added to the output if lineNumber = true.
Throws:
java.io.IOException - If System.in can not be read form.

getHead

public static java.lang.String getHead(java.lang.String source)
Helper function to return the head of a String. The head is defined as the first token that is read by StringTokenizer.
Parameters:
source - The source String.
Returns:
The head of the source String, or null if there is not one.
See Also:
getTail(String source)

getTail

public static java.lang.String getTail(java.lang.String source)
Helper function to return the tail of a String. The tail is defined as that which is left after removing the string head, see getHead(String source).
Parameters:
source - The source String.
Returns:
The tail of the source String, or null if there is not one.
See Also:
getHead(String source)

getQuote

public static java.lang.String getQuote(java.lang.String source,
                              int number)
Helper function to get quotes from the source String. The nth (number) quote is fetched. Quotes are string surrounded by '"'
Parameters:
source - The string to search for quotes.
number - The nth quote to fetch.
Returns:
The nth quote String, or null if one can not be found.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD