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
-
SLASH
-
-
Util()
-
-
bug(Exception)
-
-
bug(String)
- record that we have hit a program bug!!!
-
capitalise(String)
- capitalise a String (whatever the starting case)
-
deQuote(String)
- remove balanced quotes from ends of (trimmed) string, else no action
-
escape(String)
- escape characters in an XML string (' -> ' , etc); also escape non-XML
characters
-
freeMemory(long)
- runs the garbage collector if memory drops below mem.
-
getDate(int, int, int, int, int, int)
- create from a date; if hrs, sec are negative, they are ignored
-
getIntFromHex(String)
- horrid, but I couldn't find if Java reads hex.
-
getPWDName()
- get current directory
-
indexOfBalancedBracket(char, String)
- return index of balanced bracket; -1 for none.
-
isRegisteredApplet(Applet)
- retrive that an object is an applet rather than an application.
-
isRightMouseClick(MouseEvent)
- a crude way of identifying a right mouse click (because I
left the Java book behind)
-
longFromDate(Date)
- get a long from a Date (should be easy, but isn't)
-
makeAbsoluteURL(Applet, String)
- If a URL is relative, make it absolute against either the current
directory (application) or codebase (applet)
-
makeAbsoluteURL(String)
- If a URL is relative, make it absolute against the current directory.
-
quoteConcatenate(String[])
- concatenate strings into quote-separated string
-
readByteArray(DataInputStream)
- reads a byte array from DataInputStream, *including* line feeds
-
readByteArray(String)
- reads a byte array from file, *including* line feeds
-
registerApplet(Applet)
- record that an object is an applet rather than an application.
-
removeHTML(String)
- remove balanced (well-formed) markup from a string.
-
spaces(int)
- make a String of a given number of spaces
-
split(String)
- splits a whitespace-separated set of tokens into a String[]
-
string2Bytes(String)
- converts a string to its byte[] equivalent
-
stripNewlines(byte[])
- strip linefeeds from a byte array
-
substituteStrings(String, String[], String[])
- make substitutions in a string.
-
toCamelCase(String)
-
SLASH
public static final String SLASH
Util
public Util()
spaces
public static String spaces(int nspace)
- make a String of a given number of spaces
deQuote
public static String deQuote(String s)
- remove balanced quotes from ends of (trimmed) string, else no action
indexOfBalancedBracket
public static int indexOfBalancedBracket(char lbrack,
String s)
- return index of balanced bracket; -1 for none. String MUST start
with '('
quoteConcatenate
public static String quoteConcatenate(String s[])
- concatenate strings into quote-separated string
- Parameters:
- String[] - s strings to be concatenated
- Returns:
- String concatenated string
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)
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"
bug
public static void bug(String s)
- record that we have hit a program bug!!!
bug
public static void bug(Exception e)
longFromDate
public static long longFromDate(Date d)
- get a long from a Date (should be easy, but isn't)
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
getPWDName
public static String getPWDName()
- get current directory
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"
capitalise
public static String capitalise(String s)
- capitalise a String (whatever the starting case)
toCamelCase
public static String toCamelCase(String s)
escape
public static String escape(String s)
- escape characters in an XML string (' -> ' , etc); also escape non-XML
characters
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
getIntFromHex
public static int getIntFromHex(String hex)
- horrid, but I couldn't find if Java reads hex. Crude; no exceptions thrown
readByteArray
public static byte[] readByteArray(String filename) throws FileNotFoundException, IOException
- reads a byte array from file, *including* line feeds
readByteArray
public static byte[] readByteArray(DataInputStream d) throws IOException
- reads a byte array from DataInputStream, *including* line feeds
stripNewlines
public static byte[] stripNewlines(byte b[])
- strip linefeeds from a byte array
string2Bytes
public static byte[] string2Bytes(String s)
- converts a string to its byte[] equivalent
isRightMouseClick
public static boolean isRightMouseClick(MouseEvent event)
- a crude way of identifying a right mouse click (because I
left the Java book behind)
registerApplet
public static void registerApplet(Applet applet)
- record that an object is an applet rather than an application.
call from applet's init() method
isRegisteredApplet
public static boolean isRegisteredApplet(Applet applet)
- retrive that an object is an applet rather than an application.
must have been registered above
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
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