|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--gishur.core.StdComparitor
Standard Comparitor
type. Compares numbers, strings, characters,
boolean-values and Items
. New Comparitors
should be derived from this class. The most important method
compare(Object,Object)
is best overridden in the following way:
public short compare(Object o1,Object o2) { ... // call own compare-methods with 'return...', e.g. if ((o1 instanceof MyObject) && (o2 instanceOf MyObject)) return compare((MyObject)o1,(MyObject)o2); // calls a method which compares MyObject-objects and finishes this method return super.compare(o1,o2); // try to perform other comparisons and throw an // Exception, if all trials fail }
Fields inherited from interface gishur.core.Comparitor |
BIGGER, EQUAL, SMALLER |
Constructor Summary | |
StdComparitor()
|
Method Summary | |
short |
compare(java.lang.Boolean b1,
java.lang.Boolean b2)
Compares two java.lang.Boolean -objects. |
short |
compare(java.lang.Character c1,
java.lang.Character c2)
Compares two Character -objects using their
charValue() -method. |
short |
compare(java.lang.Number n1,
java.lang.Number n2)
Compares two java.lang.Number s. |
short |
compare(java.lang.Object o1,
java.lang.Object o2)
Overrides Comparitor.compare(Object,Object) . |
short |
compare(java.lang.String s1,
java.lang.String s2)
Compares two String s using the compareTo(String)
-method of class String in package java.lang . |
short |
compareHash(java.lang.Object o1,
java.lang.Object o2)
Compares two objects using their hash-codes. |
java.lang.String |
toString()
Overrids java.lang.Object.toString() . |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public StdComparitor()
Method Detail |
public java.lang.String toString()
java.lang.Object.toString()
.toString
in class java.lang.Object
Object.toString()
public short compare(java.lang.String s1, java.lang.String s2)
String
s using the compareTo(String)
-method of class String
in package java.lang
.s1,s2
- two Strings
to compareComparitor.BIGGER
,
Comparitor.SMALLER
or Comparitor.EQUAL
)public short compare(java.lang.Character c1, java.lang.Character c2)
Character
-objects using their
charValue()
-method.c1,c2
- Character
-objects to compareComparitor.BIGGER
,
Comparitor.SMALLER
or Comparitor.EQUAL
)public short compare(java.lang.Number n1, java.lang.Number n2)
java.lang.Number
s.n1,n2
- Number
-objects to compare.Comparitor.BIGGER
,
Comparitor.SMALLER
or Comparitor.EQUAL
)public short compare(java.lang.Boolean b1, java.lang.Boolean b2)
java.lang.Boolean
-objects. false
is supposed to be 'smaller' than true
.b1,b2
- two Boolean
-values to compare.Comparitor.BIGGER
,
Comparitor.SMALLER
or Comparitor.EQUAL
)public short compareHash(java.lang.Object o1, java.lang.Object o2)
o1,o2
- two Object
s to compareComparitor.BIGGER
,
Comparitor.SMALLER
or Comparitor.EQUAL
)public short compare(java.lang.Object o1, java.lang.Object o2)
Comparitor.compare(Object,Object)
. If an argument is of
type KeyValueHolder
, its key will be compared to the other object.
If both arguments are null
, Comparitor.EQUAL
will be
returned, if only one argument is null
, it will be supposed
to be the smaller one.
If no argument is null
the method checks the type of the
arguments and calls the matching compare-method.compare
in interface Comparitor
o1,o2
- two objects to compareComparitor.BIGGER
,
Comparitor.SMALLER
or Comparitor.EQUAL
)Comparitor.compare(java.lang.Object, java.lang.Object)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |