org.hecl
Class Compare
java.lang.Object
org.hecl.Compare
public class Compare
- extends java.lang.Object
The Compare
class exists to compare things in different ways.
- Version:
- 1.0
- Author:
- David N. Welton
Method Summary |
static int |
compareProc(Thing a,
Thing b,
Interp interp,
Thing sortproc)
The compareProc method takes two things to
compare, an interpreter, andthe name of a proc to compare the
two things with. |
static int |
compareString(Thing a,
Thing b)
compareString compares two Things as strings. |
static boolean |
same(Thing t1,
Thing t2)
same checks if two Things as the same. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NUMCOMPARE
public static final int NUMCOMPARE
- See Also:
- Constant Field Values
STRINGCOMPARE
public static final int STRINGCOMPARE
- See Also:
- Constant Field Values
PROCCOMPARE
public static final int PROCCOMPARE
- See Also:
- Constant Field Values
Compare
public Compare()
same
public static boolean same(Thing t1,
Thing t2)
same
checks if two Things as the same. In case the
parameters are ObjectThing
s, they are the same only if
they are identical, for all other Thing
s this function
calls compareString
to check for sameness.
This subtle difference in comparison is necessary since
ObjectThing.toString()
may yield the same string
representation even when the objects are different (happens i.e. on
Nokia 6630 for instances of javax.microeditoion.lcdui.Command
.
- Parameters:
t1
- a Thing
valuet2
- a Thing
value
- Returns:
boolean
indicating sameness.
compareString
public static int compareString(Thing a,
Thing b)
compareString
compares two Things as strings. This can't
fail, because all Things may be represented as strings.
- Parameters:
a
- a Thing
valueb
- a Thing
value
- Returns:
- an
int
value
- Throws:
HeclException
compareProc
public static int compareProc(Thing a,
Thing b,
Interp interp,
Thing sortproc)
throws HeclException
- The
compareProc
method takes two things to
compare, an interpreter, andthe name of a proc to compare the
two things with. It puts together a codething, runs it, and
returns the result: 0 if the two things are equal, -1 if A is
"less than" B, and 1 if 1 if A is "greater than" B.
- Parameters:
a
- a Thing
valueb
- a Thing
valueinterp
- an Interp
valuesortproc
- a Thing
value
- Returns:
- an
int
value
- Throws:
HeclException
- if an error occurs