jumbo.xml.util
Class Util

java.lang.Object
  |
  +--jumbo.xml.util.Util

public class Util
extends java.lang.Object

A number of miscellaneous tools. Originally devised for jumbo.sgml, now rewritten for jumbo.xml. Use these at your peril - some will be phased out


Field Summary
static java.lang.String AMP
           
static java.lang.String APOS
           
static java.lang.String ATSIGN
           
static java.lang.String BACKSLASH
           
static int BR_LOOKAHEAD
          lookahead for bufferedReader
static java.lang.String CARET
           
static int CASE
          case sensitivity flags - used throughout jumbo.xml
static java.lang.String COLON
           
static java.lang.String COMMA
           
static java.lang.String DOLLAR
           
static java.lang.String DOS
           
static java.lang.String EQUALS
           
static java.lang.String FORMAT_ASCII
           
static java.lang.String FORMAT_DOS
           
static java.lang.String FORMAT_EQUALS
           
static java.lang.String FORMFEED
           
static java.lang.String HASH
           
static int IGNORECASE
           
static java.lang.String LANGLE
           
static java.lang.String LBRAK
           
static java.lang.String LCURLY
           
static java.lang.String LSQUARE
           
static java.lang.String MINUS
           
static java.lang.String NEWLINE
           
static java.lang.String NONWHITEPUNC
           
static java.lang.String PERCENT
           
static java.lang.String PERIOD
           
static java.lang.String PIPE
           
static java.lang.String PLUS
           
static java.lang.String POUND
           
static java.lang.String PUNC
           
static java.lang.String QUERY
           
static java.lang.String QUOT
           
static java.lang.String RANGLE
           
static java.lang.String RBRAK
           
static java.lang.String RCURLY
           
static java.lang.String RETURN
           
static java.lang.String[] ROMAN_NUMERALS
          a list of the first few Roman numerals (e.g.
static java.lang.String RSQUARE
           
static java.lang.String SEMICOLON
           
static java.lang.String SHRIEK
           
static java.lang.String SLASH
           
static java.lang.String SPACE
           
static java.lang.String STAR
           
static java.lang.String TAB
           
static java.lang.String TILDE
           
static java.lang.String UNDER
           
static int UNKNOWN
          general code for unset or unknown variables
static java.lang.String WHITESPACE
           
static java.lang.String X_COMMENTC
           
static java.lang.String X_COMMENTO
           
static java.lang.String X_DOCTYPEE
           
static java.lang.String X_DOCTYPEO
           
static java.lang.String X_ELEMDEFC
           
static java.lang.String X_ELEMDEFO
           
static java.lang.String X_EMPTAGC
           
static java.lang.String X_EMPTAGO
           
static java.lang.String X_ENTDEFC
           
static java.lang.String X_ENTDEFO
           
static java.lang.String X_ETAGC
           
static java.lang.String X_ETAGO
           
static java.lang.String X_GENENTC
           
static java.lang.String X_GENENTO
           
static java.lang.String X_PARAMENTC
           
static java.lang.String X_PARAMENTDEFC
           
static java.lang.String X_PARAMENTDEFO
           
static java.lang.String X_PARAMENTO
           
static java.lang.String X_STAGC
           
static java.lang.String X_STAGO
           
static java.lang.String X_STARTDEF
           
 
Constructor Summary
Util()
           
 
Method Summary
static void addEnumerationToVector(java.util.Vector v, java.util.Enumeration enum)
          add the elements of an Enumeration to a Vector.
 java.lang.String addToClasspath(java.lang.String extraPath)
          adds to the classpath and resets the system property
static void addToSystemProperties(java.lang.String urlString)
          load a file/url into the system properties,
static java.util.Vector alternativeStringTokenizer(java.lang.String s, char delim)
          tokenize the string including adjacent delimiters (e.g.
static java.util.Hashtable and(java.util.Hashtable h1, java.util.Hashtable h2)
          create Hashtable with elements common to h1 and h2.
static java.util.Vector and(java.util.Vector v1, java.util.Vector v2)
          create Vector with elements common to v1 and v2.
static java.util.Hashtable andTables(java.util.Hashtable a, java.util.Hashtable b)
          AND 2 Hashtables - inefficient except for small tables.
static java.util.Vector andVectors(java.util.Vector a, java.util.Vector b)
          finds elements common to 2 vectors.
static void bug(java.lang.Exception e)
           
static void bug(java.lang.String s)
          record that we have hit a program bug!!!
static java.lang.String capitalise(java.lang.String s)
          capitalise a String (whatever the starting case)
static java.util.Vector convertFormat(java.util.Vector vector, java.lang.String format)
          converts character format within a Vector of Strings.
static void copyFile(java.io.File inFile, java.io.File outFile)
          copy one file to another (I suspect there is a better way
static double cos(java.lang.String fString)
           
static java.lang.String createCommaSeparatedStrings(java.util.Vector v)
           
static java.io.File createNewFile(java.lang.String fileName)
          create new file, including making directory if required This seems to be a mess - f.createNewFile() doesn't seem to work A directory should have a trailing file.separator
static boolean deleteFile(java.io.File file, boolean deleteDirectory)
          delete a file.
static java.lang.String deQuote(java.lang.String s)
          remove balanced quotes from ends of (trimmed) string, else no action
static java.lang.String dump(java.net.URL url)
          reads a stream from url and outputs it as integer values of the characters and as strings.
static boolean equals(java.lang.Object obj1, java.lang.Object obj2)
          compares tow object using equals() - allows for null objects.
static boolean equals(java.lang.String string1, java.lang.String string2, int sensitivity)
          convenience function for comparing strings using Util.CASE/IGNORECASE
static void error(java.lang.String s)
          Error message - nothing fancy at present.
static java.lang.String escape(java.lang.String s)
          default escape characters in an XML string (' -> ' , etc); also escape non-XML characters (e.g.
static java.lang.String escape(java.lang.String s, char[] escapes, java.lang.String[] escape1)
          escape characters in an XML string; also escape non-XML characters (e.g.
static void flush(java.lang.String s)
          output String and flush()
static void freeMemory(long mem)
          runs the garbage collector if memory drops below mem.
static java.util.Vector getCommaSeparatedStrings(java.lang.String s)
          parse comma-separated Strings.
static java.io.FileOutputStream getFileOutputStream(java.lang.String fileName)
          get an OutputStream from a file or URL.
static int getIntegerFromRoman(java.lang.String roman)
          translate Roman Numerals up to 50 (!!!) Some normalisation is performed.
static int getIntFromHex(java.lang.String hex)
          Translates a Hex number to its int equivalent.
static java.lang.Object getNewInstance(java.lang.String className)
          gets a new instance of a class from a hashtable because normal methods are very slow
static java.lang.String getPWDName()
          get current directory
static java.util.Vector getRepeatedValues(java.util.Vector v)
          returns a vector of all repeated values in v.
static java.lang.String getSuffix(java.lang.String filename)
          gets suffix from filename
static int indexOf(java.lang.String string, java.lang.String[] strings, int caseSensitivity)
          get the index of a String in an array
static int indexOfBalancedBracket(char lbrack, java.lang.String s)
          return index of balanced bracket; -1 for none.
static java.util.Hashtable invert(java.util.Hashtable table)
          invert a Hashtable by interchanging keys and values.
static boolean isAllowedFormat(java.lang.String format)
           
static boolean isRegisteredApplet(java.applet.Applet applet)
          retrive that an object is an applet rather than an application.
static boolean isRightMouseClick(java.awt.event.MouseEvent event)
          a crude way of identifying a right mouse click (because I left the Java book behind)
static java.lang.String leftTrim(java.lang.String s)
          remove leading blanks
static double log(java.lang.String fString)
           
static void main(java.lang.String[] args)
           
static java.lang.String makeAbsoluteURL(java.applet.Applet applet, java.lang.String url)
          If a URL is relative, make it absolute against either the current directory (application) or codebase (applet)
static java.lang.String makeAbsoluteURL(java.lang.String url)
          If a URL is relative, make it absolute against the current directory.
static java.lang.String makeDirectory(java.lang.String urlString)
          truncate filename suffix to make a directory name (without file.separator)
static void message(java.lang.String s)
          message - nothing fancy at present
static java.lang.String normaliseWhitespace(java.lang.String s)
          normalise whitespace in a String (all whitespace is transformed to single spaces and the string is NOT trimmed
static java.util.Hashtable not(java.util.Hashtable h1, java.util.Hashtable h2)
          create Hashtable with elements in to h1 but not h2.
static java.util.Vector not(java.util.Vector v1, java.util.Vector v2)
          create Vector with elements in v1 but not v2.
static java.util.Hashtable or(java.util.Hashtable h1, java.util.Hashtable h2)
          create Hashtable with elements in to h1 but not h2.
static java.util.Vector or(java.util.Vector v1, java.util.Vector v2)
          create Vector with elements in v1 but not v2.
static java.util.Hashtable orTables(java.util.Hashtable a, java.util.Hashtable b)
          OR 2 Hashtables - inefficient except for small tables.
static java.lang.String outputFloat(int nPlaces, int nDec, double value)
          format e.g.
static java.lang.String outputInteger(int nPlaces, int value)
          this is a mess
static java.util.Vector parseWhitespaceQuotedFields(java.lang.String s)
          parse whitespace-separated tokens interspersed with quoted strings, e.g.
this is "a quoted string" and 'another token' as well
parses to:
this/is/a quoted string/and/another token/as well
static void printChar()
           
static java.lang.String quoteConcatenate(java.lang.String[] s)
          concatenate strings into quote-separated string
static byte[] readByteArray(java.io.DataInputStream d)
          reads a byte array from DataInputStream, *including* line feeds
static byte[] readByteArray(java.lang.String filename)
          reads a byte array from file, *including* line feeds
static void readZip(java.lang.String fileName)
          read a Zipfile
static void registerApplet(java.applet.Applet applet)
          record that an object is an applet rather than an application.
static java.lang.String removeHTML(java.lang.String s)
          remove balanced (well-formed) markup from a string.
static java.lang.String rightTrim(java.lang.String s)
          remove trailing blanks
static void setSystemProperty(java.lang.String property, java.lang.String value)
          add a property to the System ones.
static double sin(java.lang.String fString)
           
static int skipWhite(java.io.BufferedReader bReader)
          skip white lines and end with first non-white line.
static void sort(java.lang.Object[] objs)
          sort an object array - very inefficient
static void sortVector(java.util.Vector v)
          sort a Vector - VERY crude and inefficient
static java.lang.String spaces(int nspace)
          make a String of a given number of spaces
static java.lang.String[] split(java.lang.String s)
          splits a whitespace-separated set of tokens into a String[]
static java.lang.String stripISOControls(java.lang.String s)
          remove all control (non-printing) characters
static byte[] stripNewlines(byte[] b)
          strip linefeeds from a byte array
static java.lang.String substituteDOSbyAscii(java.lang.String s)
          substitute certain DOS-compatible diacriticals by the Unicode value.
static java.lang.String substituteEquals(java.lang.String s)
          substitute hex representation of character, e.g.
static java.lang.String substituteString(java.lang.String s, java.lang.String oldSubstring, java.lang.String newSubstring, int count)
          make substitutions in a string.
static java.lang.String substituteStrings(java.lang.String s, java.lang.String[] oldSubstrings, java.lang.String[] newSubstrings)
          make substitutions in a string.
static java.lang.String substring(java.lang.String string, java.lang.String startPos, java.lang.String lenString)
          supports XSL substring
static java.lang.String toCamelCase(java.lang.String s)
           
static java.lang.String truncate(java.lang.String s, int maxlength)
          return the first n characters of a string and add ellipses if truncated
static void warning(java.lang.String s)
          Warning message - nothing fancy at present
static java.util.Hashtable xorTables(java.util.Hashtable a, java.util.Hashtable b)
          XOR 2 Hashtables - inefficient except for small tables.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORMAT_ASCII

public static final java.lang.String FORMAT_ASCII

FORMAT_DOS

public static final java.lang.String FORMAT_DOS

FORMAT_EQUALS

public static final java.lang.String FORMAT_EQUALS

SPACE

public static final java.lang.String SPACE

TAB

public static final java.lang.String TAB

RETURN

public static final java.lang.String RETURN

NEWLINE

public static final java.lang.String NEWLINE

FORMFEED

public static final java.lang.String FORMFEED

WHITESPACE

public static final java.lang.String WHITESPACE

LBRAK

public static final java.lang.String LBRAK

RBRAK

public static final java.lang.String RBRAK

SHRIEK

public static final java.lang.String SHRIEK

QUOT

public static final java.lang.String QUOT

POUND

public static final java.lang.String POUND

DOLLAR

public static final java.lang.String DOLLAR

PERCENT

public static final java.lang.String PERCENT

CARET

public static final java.lang.String CARET

AMP

public static final java.lang.String AMP

STAR

public static final java.lang.String STAR

UNDER

public static final java.lang.String UNDER

MINUS

public static final java.lang.String MINUS

PLUS

public static final java.lang.String PLUS

EQUALS

public static final java.lang.String EQUALS

LCURLY

public static final java.lang.String LCURLY

RCURLY

public static final java.lang.String RCURLY

LSQUARE

public static final java.lang.String LSQUARE

RSQUARE

public static final java.lang.String RSQUARE

TILDE

public static final java.lang.String TILDE

HASH

public static final java.lang.String HASH

COLON

public static final java.lang.String COLON

SEMICOLON

public static final java.lang.String SEMICOLON

ATSIGN

public static final java.lang.String ATSIGN

APOS

public static final java.lang.String APOS

COMMA

public static final java.lang.String COMMA

PERIOD

public static final java.lang.String PERIOD

SLASH

public static final java.lang.String SLASH

QUERY

public static final java.lang.String QUERY

LANGLE

public static final java.lang.String LANGLE

RANGLE

public static final java.lang.String RANGLE

PIPE

public static final java.lang.String PIPE

BACKSLASH

public static final java.lang.String BACKSLASH

NONWHITEPUNC

public static final java.lang.String NONWHITEPUNC

PUNC

public static final java.lang.String PUNC

X_STAGO

public static final java.lang.String X_STAGO

X_STAGC

public static final java.lang.String X_STAGC

X_ETAGO

public static final java.lang.String X_ETAGO

X_ETAGC

public static final java.lang.String X_ETAGC

X_EMPTAGO

public static final java.lang.String X_EMPTAGO

X_EMPTAGC

public static final java.lang.String X_EMPTAGC

X_STARTDEF

public static final java.lang.String X_STARTDEF

X_COMMENTO

public static final java.lang.String X_COMMENTO

X_COMMENTC

public static final java.lang.String X_COMMENTC

X_ENTDEFO

public static final java.lang.String X_ENTDEFO

X_ENTDEFC

public static final java.lang.String X_ENTDEFC

X_PARAMENTDEFO

public static final java.lang.String X_PARAMENTDEFO

X_PARAMENTDEFC

public static final java.lang.String X_PARAMENTDEFC

X_ELEMDEFO

public static final java.lang.String X_ELEMDEFO

X_ELEMDEFC

public static final java.lang.String X_ELEMDEFC

X_PARAMENTO

public static final java.lang.String X_PARAMENTO

X_PARAMENTC

public static final java.lang.String X_PARAMENTC

X_GENENTO

public static final java.lang.String X_GENENTO

X_GENENTC

public static final java.lang.String X_GENENTC

X_DOCTYPEO

public static final java.lang.String X_DOCTYPEO

X_DOCTYPEE

public static final java.lang.String X_DOCTYPEE

UNKNOWN

public static final int UNKNOWN
general code for unset or unknown variables

CASE

public static final int CASE
case sensitivity flags - used throughout jumbo.xml

IGNORECASE

public static final int IGNORECASE

BR_LOOKAHEAD

public static final int BR_LOOKAHEAD
lookahead for bufferedReader

ROMAN_NUMERALS

public static java.lang.String[] ROMAN_NUMERALS
a list of the first few Roman numerals (e.g. for chapters)

DOS

public static final java.lang.String DOS
Constructor Detail

Util

public Util()
Method Detail

deleteFile

public static boolean deleteFile(java.io.File file,
                                 boolean deleteDirectory)
delete a file. If directory==true then file will be recursively deleted

copyFile

public static void copyFile(java.io.File inFile,
                            java.io.File outFile)
                     throws java.io.FileNotFoundException,
                            java.io.IOException
copy one file to another (I suspect there is a better way

dump

public static java.lang.String dump(java.net.URL url)
                             throws java.lang.Exception
reads a stream from url and outputs it as integer values of the characters and as strings. Emulates UNIX od().
Parameters:
URL - url the input
Returns:
String tabular version of input (in 10-column chunks)

flush

public static void flush(java.lang.String s)
output String and flush()

spaces

public static java.lang.String spaces(int nspace)
make a String of a given number of spaces

getSuffix

public static java.lang.String getSuffix(java.lang.String filename)
gets suffix from filename

skipWhite

public static int skipWhite(java.io.BufferedReader bReader)
                     throws java.lang.Exception
skip white lines and end with first non-white line. Leaves bReader ready to read first non-white line
Returns:
int number of lines skipped

truncate

public static java.lang.String truncate(java.lang.String s,
                                        int maxlength)
return the first n characters of a string and add ellipses if truncated
Parameters:
String - s string to be output
Returns:
String the (possibly) truncated string

getIntegerFromRoman

public static int getIntegerFromRoman(java.lang.String roman)
translate Roman Numerals up to 50 (!!!) Some normalisation is performed. Failure returns -1

setSystemProperty

public static void setSystemProperty(java.lang.String property,
                                     java.lang.String value)
add a property to the System ones. Don't know if this is a good idea...

addToSystemProperties

public static void addToSystemProperties(java.lang.String urlString)
                                  throws java.io.IOException
load a file/url into the system properties,

getNewInstance

public static java.lang.Object getNewInstance(java.lang.String className)
                                       throws java.lang.Exception
gets a new instance of a class from a hashtable because normal methods are very slow

deQuote

public static java.lang.String deQuote(java.lang.String s)
remove balanced quotes from ends of (trimmed) string, else no action

rightTrim

public static java.lang.String rightTrim(java.lang.String s)
remove trailing blanks

leftTrim

public static java.lang.String leftTrim(java.lang.String s)
remove leading blanks

indexOfBalancedBracket

public static int indexOfBalancedBracket(char lbrack,
                                         java.lang.String s)
return index of balanced bracket; -1 for none. String MUST start with '('

getCommaSeparatedStrings

public static java.util.Vector getCommaSeparatedStrings(java.lang.String s)
                                                 throws java.lang.Exception
parse comma-separated Strings. Note fields can be "" (as in ,,,) and fields can be quoted "...". If so, embedded quotes are represented as "", e.g. A," this is a ""B"" character",C. An unbalanced quote returns a mess
Parameters:
String - s to be parsed(null returns null)
Returns:
Vector the vector of Strings - any error returns null

createCommaSeparatedStrings

public static java.lang.String createCommaSeparatedStrings(java.util.Vector v)
                                                    throws java.lang.Exception

alternativeStringTokenizer

public static java.util.Vector alternativeStringTokenizer(java.lang.String s,
                                                          char delim)
tokenize the string including adjacent delimiters (e.g. "foo$$bar$", "$" would contain the tokens "foo", "", "bar" and "")

parseWhitespaceQuotedFields

public static java.util.Vector parseWhitespaceQuotedFields(java.lang.String s)
parse whitespace-separated tokens interspersed with quoted strings, e.g.
this is "a quoted string" and 'another token' as well
parses to:
this/is/a quoted string/and/another token/as well
Parameters:
String - s the string to be parsed
Returns:
Vector of strings (size = 0 if s is whitespace);

quoteConcatenate

public static java.lang.String quoteConcatenate(java.lang.String[] s)
concatenate strings into quote-separated string
Parameters:
String[] - s strings to be concatenated
Returns:
String concatenated string

split

public static java.lang.String[] split(java.lang.String s)
splits a whitespace-separated set of tokens into a String[]
Parameters:
String - s string to be split
Returns:
String[] result of splitting (null if s==null)

indexOf

public static int indexOf(java.lang.String string,
                          java.lang.String[] strings,
                          int caseSensitivity)
get the index of a String in an array
Parameters:
String - string the string to search for
String[] - strings the array of strings
int - case-sensitive? CASE/IGNORECASE
Returns:
index of string else -1 if not found

equals

public static boolean equals(java.lang.String string1,
                             java.lang.String string2,
                             int sensitivity)
convenience function for comparing strings using Util.CASE/IGNORECASE
Parameters:
String - string1
String - string2
int - sensitivity (CASE/IGNORECASE)
Returns:
boolean true if IGNORECASE ans string1.equalsIgnoreCase(string2) or string1.equals(string2)

removeHTML

public static java.lang.String removeHTML(java.lang.String s)
remove balanced (well-formed) markup from a string. Crude (i.e. not fully XML-compliant);
Example: "This is <A HREF="foo">bar</A> and </BR> a break" goes to "This is bar and a break"

warning

public static void warning(java.lang.String s)
Warning message - nothing fancy at present

message

public static void message(java.lang.String s)
message - nothing fancy at present

error

public static void error(java.lang.String s)
Error message - nothing fancy at present. Display in Text frame

bug

public static void bug(java.lang.String s)
record that we have hit a program bug!!!

bug

public static void bug(java.lang.Exception e)

createNewFile

public static java.io.File createNewFile(java.lang.String fileName)
                                  throws java.io.IOException
create new file, including making directory if required This seems to be a mess - f.createNewFile() doesn't seem to work A directory should have a trailing file.separator

getPWDName

public static java.lang.String getPWDName()
get current directory

substituteString

public static java.lang.String substituteString(java.lang.String s,
                                                java.lang.String oldSubstring,
                                                java.lang.String newSubstring,
                                                int count)
make substitutions in a string. If oldSubtrings = "A" and newSubstrings = "aa" then count occurrences of "A" in s are replaced with "aa", etc. "AAA" count=2 would be replaced by "aaaaA"
Parameters:
int - count number of substitutions. if <= 0, then infinite

substituteStrings

public static java.lang.String substituteStrings(java.lang.String s,
                                                 java.lang.String[] oldSubstrings,
                                                 java.lang.String[] newSubstrings)
make substitutions in a string. If oldSubtrings = {"A", "BB", "C"} and newSubstrings = {"aa", "b", "zz"} then every occurrence of "A" in s is replaced with "aa", etc. "BBB" would be replaced by "bB"

substituteDOSbyAscii

public static java.lang.String substituteDOSbyAscii(java.lang.String s)
substitute certain DOS-compatible diacriticals by the Unicode value. Not guaranteed to be correct. Example 130 is e-acute (==

substituteEquals

public static java.lang.String substituteEquals(java.lang.String s)
substitute hex representation of character, e.g. =2E by char(46). If line ends with =, ignore that character.
Parameters:
String - s string to be substituted (iteratively from left)
Returns:
String result

isAllowedFormat

public static boolean isAllowedFormat(java.lang.String format)

convertFormat

public static java.util.Vector convertFormat(java.util.Vector vector,
                                             java.lang.String format)
converts character format within a Vector of Strings. Some formats such as '=' escaping may require lines to be joined. Original Vector is unaltered.

capitalise

public static java.lang.String capitalise(java.lang.String s)
capitalise a String (whatever the starting case)

toCamelCase

public static java.lang.String toCamelCase(java.lang.String s)

escape

public static java.lang.String escape(java.lang.String s,
                                      char[] escapes,
                                      java.lang.String[] escape1)
escape characters in an XML string; also escape non-XML characters (e.g. eacute => é). If escapes==null only escape non-XML

escape

public static java.lang.String escape(java.lang.String s)
default escape characters in an XML string (' -> ' , etc); also escape non-XML characters (e.g. eacute => é)

equals

public static boolean equals(java.lang.Object obj1,
                             java.lang.Object obj2)
compares tow object using equals() - allows for null objects. if either object is null returns false

freeMemory

public static void freeMemory(long mem)
runs the garbage collector if memory drops below mem. (I use a value of 300000 - your mileage may vary). Potentially used in loops for processing input and creation of objects

addToClasspath

public java.lang.String addToClasspath(java.lang.String extraPath)
adds to the classpath and resets the system property
Parameters:
String - extraPath
Returns:
String the new classpath

getIntFromHex

public static int getIntFromHex(java.lang.String hex)
Translates a Hex number to its int equivalent. Thus "FE" translates to 254. Horrid, but I couldn't find if Java reads hex. All results are >= 0. Errors return -1

readByteArray

public static byte[] readByteArray(java.lang.String filename)
                            throws java.io.FileNotFoundException,
                                   java.io.IOException
reads a byte array from file, *including* line feeds

readByteArray

public static byte[] readByteArray(java.io.DataInputStream d)
                            throws java.io.IOException
reads a byte array from DataInputStream, *including* line feeds

stripISOControls

public static java.lang.String stripISOControls(java.lang.String s)
remove all control (non-printing) characters

normaliseWhitespace

public static java.lang.String normaliseWhitespace(java.lang.String s)
normalise whitespace in a String (all whitespace is transformed to single spaces and the string is NOT trimmed

stripNewlines

public static byte[] stripNewlines(byte[] b)
strip linefeeds from a byte array

isRightMouseClick

public static boolean isRightMouseClick(java.awt.event.MouseEvent event)
a crude way of identifying a right mouse click (because I left the Java book behind)

registerApplet

public static void registerApplet(java.applet.Applet applet)
record that an object is an applet rather than an application. call from applet's init() method

isRegisteredApplet

public static boolean isRegisteredApplet(java.applet.Applet applet)
retrive that an object is an applet rather than an application. must have been registered above

makeDirectory

public static java.lang.String makeDirectory(java.lang.String urlString)
truncate filename suffix to make a directory name (without file.separator)

makeAbsoluteURL

public static java.lang.String makeAbsoluteURL(java.lang.String url)
                                        throws java.net.MalformedURLException
If a URL is relative, make it absolute against the current directory. If url already has a protocol, return unchanged

makeAbsoluteURL

public static java.lang.String makeAbsoluteURL(java.applet.Applet applet,
                                               java.lang.String url)
                                        throws java.net.MalformedURLException
If a URL is relative, make it absolute against either the current directory (application) or codebase (applet)

getFileOutputStream

public static java.io.FileOutputStream getFileOutputStream(java.lang.String fileName)
                                                    throws java.io.FileNotFoundException
get an OutputStream from a file or URL. Required (I think) because strings of the sort "file:/C:\foo\bat.txt" crash FileOutputStream, so this strips off the file:/ stuff for Windows-like stuff
Parameters:
String - fileName output file
Returns:
FileOutputStream a new (opened) FileOutputStream

readZip

public static void readZip(java.lang.String fileName)
                    throws java.io.IOException
read a Zipfile

outputInteger

public static java.lang.String outputInteger(int nPlaces,
                                             int value)
                                      throws java.lang.IllegalArgumentException
this is a mess

outputFloat

public static java.lang.String outputFloat(int nPlaces,
                                           int nDec,
                                           double value)
                                    throws java.lang.IllegalArgumentException
format e.g. f8.3 this is a mess

invert

public static java.util.Hashtable invert(java.util.Hashtable table)
invert a Hashtable by interchanging keys and values. This assumes a 1;1 mapping - if not the result is probably garbage.

andTables

public static java.util.Hashtable andTables(java.util.Hashtable a,
                                            java.util.Hashtable b)
AND 2 Hashtables - inefficient except for small tables. Finds entries with the same key and value.
Parameters:
Hashtable - a
Hashtable - b
Returns:
Hashtable contains only common entries. null if none

orTables

public static java.util.Hashtable orTables(java.util.Hashtable a,
                                           java.util.Hashtable b)
OR 2 Hashtables - inefficient except for small tables. Merges entries. if entry with the same key and different value is found, take value from first table.
Parameters:
Hashtable - a
Hashtable - b
Returns:
Hashtable contains all entries. null if none

xorTables

public static java.util.Hashtable xorTables(java.util.Hashtable a,
                                            java.util.Hashtable b)
XOR 2 Hashtables - inefficient except for small tables. omit
Parameters:
Hashtable - a
Hashtable - b
Returns:
Hashtable contains no common entries.

getRepeatedValues

public static java.util.Vector getRepeatedValues(java.util.Vector v)
returns a vector of all repeated values in v.
Parameters:
Vector - v vector to be tested
Returns:
Vector containing duplicate values. If none, returns null

andVectors

public static java.util.Vector andVectors(java.util.Vector a,
                                          java.util.Vector b)
finds elements common to 2 vectors. Very crude (O(n^2));

addEnumerationToVector

public static void addEnumerationToVector(java.util.Vector v,
                                          java.util.Enumeration enum)
add the elements of an Enumeration to a Vector.

sort

public static void sort(java.lang.Object[] objs)
sort an object array - very inefficient

printChar

public static void printChar()

sortVector

public static void sortVector(java.util.Vector v)
sort a Vector - VERY crude and inefficient

and

public static java.util.Vector and(java.util.Vector v1,
                                   java.util.Vector v2)
create Vector with elements common to v1 and v2. SLOW. Comparison is done with equals()

not

public static java.util.Vector not(java.util.Vector v1,
                                   java.util.Vector v2)
create Vector with elements in v1 but not v2. SLOW. Comparison is done with equals()

or

public static java.util.Vector or(java.util.Vector v1,
                                  java.util.Vector v2)
create Vector with elements in v1 but not v2. SLOW. Comparison is done with equals()

and

public static java.util.Hashtable and(java.util.Hashtable h1,
                                      java.util.Hashtable h2)
create Hashtable with elements common to h1 and h2. The keys are taken from h1. SLOW. Comparison is done with equals()

not

public static java.util.Hashtable not(java.util.Hashtable h1,
                                      java.util.Hashtable h2)
create Hashtable with elements in to h1 but not h2. The keys are taken from h1 SLOW. Comparison is done with equals()

or

public static java.util.Hashtable or(java.util.Hashtable h1,
                                     java.util.Hashtable h2)
create Hashtable with elements in to h1 but not h2. The keys are taken from h1 SLOW. Comparison is done with equals()

sin

public static double sin(java.lang.String fString)

cos

public static double cos(java.lang.String fString)

log

public static double log(java.lang.String fString)

substring

public static java.lang.String substring(java.lang.String string,
                                         java.lang.String startPos,
                                         java.lang.String lenString)
supports XSL substring

main

public static void main(java.lang.String[] args)