This page describes some (not all) features of the utility
classes.
-
Streams with LATIN1:
-
The stream and reader/writer classes from the Java API use
the default encoding. The project "java-unidu" contains
some classes using LATIN1 (ISO-8859-1) instead.
The class de.unidu.is.util.ISOReader is an
extension to java.io.InputStreamReader wich
always uses LATIN1 (ISO-8859-1) as encoding. The writer
corresponding class is
de.unidu.is.util.ISOWriter.
The classes de.unidu.is.util.FileISOReader
and de.unidu.is.util.FileISOWriter should be
used instead of the traditional file reader/writer.
In addition, de.unidu.is.util.URLISOReader
can be used to get a LATIN1-based reader from a URL.
-
String processing:
-
The class de.unidu.is.util.StringUtilities
provides some static methods for string processing,
e.g. for converting an array or a collection in a string,
for entity en/decoding for XML, for removing all tags, for
extracting text from HTML, for replacing text by another
text, or for removing text (originated from times before
JDK 1.4 was released).
-
XML processing:
-
The class de.unidu.is.util.XMLUtilities
provides some static methods for XML processing,
e.g. for converting an array or a collection in a string,
for conveniently parsing XML files or strings, for nicely
formatted output of XML documents, for converting HTML
streams into XHTML documents, and for text extraction via
XPath.
-
Locating files:
-
The class de.unidu.is.util.SystemUtilities
provides some static methods for find files on the
classpath. The methods scas the classpath. For each JAR,
the file must be located in the beginning
(jar:file://...!/file). For each directory,
the file must be located in that directoy or in its direct
parent directory. Some methods return the first match,
others all matches. These methods can be used for locating
configuration files.
-
Managing collections:
-
The class de.unidu.is.util.CollectionUtilities
provides some static methods for adding all objects
returned converting iterators into collections.
The class de.unidu.is.util.EmptyIterator
can be used if an iterator is required which returns no
object at all.
The class de.unidu.is.util.SingleItemIterator
can be used if an iterator over a single object is
needed.
The class de.unidu.is.util.SequenceIterator
has to initialised with an iterator which returns other
iterators. The sequence iterator then iterators over the
first returned iterator, then over the second and so on.
The class de.unidu.is.util.AcceptFilterIterator
iterates over another iterator and checks for each object
if it should be returned. For this, a sub-class has to be
created which implements the boolean
accept(Object) method.
-
Stopwatch:
-
The class de.unidu.is.util.StopWatch
provides some methods for measuring time (in
milliseconds), e.g. for simple profiling. A stop watch can
be started, stopped, restarted and reset. The average and
the total time can be formatted as strings (in
milliseconds, in seconds, and in minutes).