All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class jumbo.xml.Util

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

public class Util
extends 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

Author:
(C) P. Murray-Rust, 1998

Variable Index

 o SLASH

Constructor Index

 o Util()

Method Index

 o bug(Exception)
 o bug(String)
record that we have hit a program bug!!!
 o capitalise(String)
capitalise a String (whatever the starting case)
 o deQuote(String)
remove balanced quotes from ends of (trimmed) string, else no action
 o escape(String)
escape characters in an XML string (' -> ' , etc); also escape non-XML characters
 o freeMemory(long)
runs the garbage collector if memory drops below mem.
 o getDate(int, int, int, int, int, int)
create from a date; if hrs, sec are negative, they are ignored
 o getIntFromHex(String)
horrid, but I couldn't find if Java reads hex.
 o getPWDName()
get current directory
 o indexOfBalancedBracket(char, String)
return index of balanced bracket; -1 for none.
 o isRegisteredApplet(Applet)
retrive that an object is an applet rather than an application.
 o isRightMouseClick(MouseEvent)
a crude way of identifying a right mouse click (because I left the Java book behind)
 o longFromDate(Date)
get a long from a Date (should be easy, but isn't)
 o makeAbsoluteURL(Applet, String)
If a URL is relative, make it absolute against either the current directory (application) or codebase (applet)
 o makeAbsoluteURL(String)
If a URL is relative, make it absolute against the current directory.
 o quoteConcatenate(String[])
concatenate strings into quote-separated string
 o readByteArray(DataInputStream)
reads a byte array from DataInputStream, *including* line feeds
 o readByteArray(String)
reads a byte array from file, *including* line feeds
 o registerApplet(Applet)
record that an object is an applet rather than an application.
 o removeHTML(String)
remove balanced (well-formed) markup from a string.
 o spaces(int)
make a String of a given number of spaces
 o split(String)
splits a whitespace-separated set of tokens into a String[]
 o string2Bytes(String)
converts a string to its byte[] equivalent
 o stripNewlines(byte[])
strip linefeeds from a byte array
 o substituteStrings(String, String[], String[])
make substitutions in a string.
 o toCamelCase(String)

Variables

 o SLASH
 public static final String SLASH

Constructors

 o Util
 public Util()

Methods

 o spaces
 public static String spaces(int nspace)
make a String of a given number of spaces

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

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

 o quoteConcatenate
 public static String quoteConcatenate(String s[])
concatenate strings into quote-separated string

Parameters:
String[] - s strings to be concatenated
Returns:
String concatenated string
 o split
 public static String[] split(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)
 o removeHTML
 public static String removeHTML(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"

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

 o bug
 public static void bug(Exception e)
 o longFromDate
 public static long longFromDate(Date d)
get a long from a Date (should be easy, but isn't)

 o getDate
 public static Date getDate(int year,
                            int month,
                            int day,
                            int hrs,
                            int min,
                            int sec)
create from a date; if hrs, sec are negative, they are ignored

 o getPWDName
 public static String getPWDName()
get current directory

 o substituteStrings
 public static String substituteStrings(String s,
                                        String oldSubstrings[],
                                        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"

 o capitalise
 public static String capitalise(String s)
capitalise a String (whatever the starting case)

 o toCamelCase
 public static String toCamelCase(String s)
 o escape
 public static String escape(String s)
escape characters in an XML string (' -> ' , etc); also escape non-XML characters

 o 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

 o getIntFromHex
 public static int getIntFromHex(String hex)
horrid, but I couldn't find if Java reads hex. Crude; no exceptions thrown

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

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

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

 o string2Bytes
 public static byte[] string2Bytes(String s)
converts a string to its byte[] equivalent

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

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

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

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

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


All Packages  Class Hierarchy  This Package  Previous  Next  Index