public class InstanceComparator extends Object implements Comparator<Instance>, Serializable, RevisionHandler
Arrays
and Collections
.
Relational values are compared instance by instance with a nested
InstanceComparator.Instance
,
Arrays
,
Collections
,
Serialized FormConstructor and Description |
---|
InstanceComparator()
Initializes the comparator and includes the class in the comparison
and all attributes included.
|
InstanceComparator(boolean includeClass)
Initializes the comparator with all attributes included.
|
InstanceComparator(boolean includeClass,
String range,
boolean invert)
Initializes the comparator.
|
Modifier and Type | Method and Description |
---|---|
int |
compare(Instance inst1,
Instance inst2)
compares the two instances, returns -1 if o1 is smaller than o2, 0
if equal and +1 if greater.
|
boolean |
getIncludeClass()
Returns whether the class is included in the comparison.
|
boolean |
getInvert()
Returns whether the matching sense of the attribute range is inverted.
|
String |
getRange()
Returns the attribute range to use in the comparison.
|
String |
getRevision()
Returns the revision string.
|
static void |
main(String[] args)
for testing only.
|
void |
setIncludeClass(boolean includeClass)
Sets whether the class should be included in the comparison.
|
void |
setInvert(boolean value)
Sets whether to invert the matching sense of the attribute range.
|
void |
setRange(String value)
Sets the attribute range to use for comparison.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
equals
public InstanceComparator()
public InstanceComparator(boolean includeClass)
includeClass
- whether to include the class in the comparisonpublic InstanceComparator(boolean includeClass, String range, boolean invert)
includeClass
- whether to include the class in the comparisonrange
- the attribute range stringinverted
- whether to invert the matching sense of the att rangepublic void setIncludeClass(boolean includeClass)
includeClass
- true if to include the class in the comparisonpublic boolean getIncludeClass()
public void setRange(String value)
value
- the attribute rangepublic String getRange()
public void setInvert(boolean value)
invert
- true if to invert the matching sensepublic boolean getInvert()
public int compare(Instance inst1, Instance inst2)
compare
in interface Comparator<Instance>
inst1
- the first instance to compareinst2
- the second instance to comparepublic String getRevision()
getRevision
in interface RevisionHandler
Copyright © 2013 University of Waikato, Hamilton, NZ. All Rights Reserved.