public class InstanceComparator extends java.lang.Object implements java.util.Comparator<Instance>, java.io.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,
java.lang.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.
|
java.lang.String |
getRange()
Returns the attribute range to use in the comparison.
|
java.lang.String |
getRevision()
Returns the revision string.
|
static void |
main(java.lang.String[] args)
for testing only.
|
void |
setIncludeClass(boolean includeClass)
Sets whether the class should be included in the comparison.
|
void |
setInvert(boolean invert)
Sets whether to invert the matching sense of the attribute range.
|
void |
setRange(java.lang.String value)
Sets the attribute range to use for comparison.
|
public InstanceComparator()
public InstanceComparator(boolean includeClass)
includeClass
- whether to include the class in the comparisonpublic InstanceComparator(boolean includeClass, java.lang.String range, boolean invert)
includeClass
- whether to include the class in the comparisonrange
- the attribute range stringinvert
- 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(java.lang.String value)
value
- the attribute rangepublic java.lang.String getRange()
public void setInvert(boolean invert)
invert
- true if to invert the matching sensepublic boolean getInvert()
public int compare(Instance inst1, Instance inst2)
compare
in interface java.util.Comparator<Instance>
inst1
- the first instance to compareinst2
- the second instance to comparepublic java.lang.String getRevision()
getRevision
in interface RevisionHandler
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception