public static class Sorter.SortRule extends java.lang.Object implements java.util.Comparator<Sorter.InstanceHolder>
| Modifier and Type | Field and Description |
|---|---|
protected Attribute |
m_attribute
The actual attribute to compare on
|
protected java.lang.String |
m_attributeNameOrIndex
Name or index of the attribute to compare on
|
protected boolean |
m_descending
True for descending instead of ascending order
|
| Constructor and Description |
|---|
SortRule()
Constructor
|
SortRule(java.lang.String setup)
Constructor
|
SortRule(java.lang.String att,
boolean descending)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
int |
compare(Sorter.InstanceHolder o1,
Sorter.InstanceHolder o2)
Compare two instances according to the rule
|
java.lang.String |
getAttribute()
Get the name or index of the attribute to sort on
|
boolean |
getDescending()
Return true if the sort is descending
|
void |
init(Environment env,
Instances structure)
Initialize the rule
|
protected void |
parseFromInternal(java.lang.String setup) |
void |
setAttribute(java.lang.String att)
Set the name or index of the attribute to sort on
|
void |
setDescending(boolean d)
Set whether the sort should be descending rather than ascending
|
java.lang.String |
toString()
Prints the rule in human readable format
|
java.lang.String |
toStringInternal()
Gets the rule in internal format
|
protected java.lang.String m_attributeNameOrIndex
protected Attribute m_attribute
protected boolean m_descending
public SortRule(java.lang.String att,
boolean descending)
att - the name or index of the attribute to compare ondescending - true if order should be descendingpublic SortRule()
public SortRule(java.lang.String setup)
setup - the definition of a sort ruleprotected void parseFromInternal(java.lang.String setup)
public java.lang.String toStringInternal()
public java.lang.String toString()
toString in class java.lang.Objectpublic void setAttribute(java.lang.String att)
att - the name or index of tha attribute to sort onpublic java.lang.String getAttribute()
public void setDescending(boolean d)
d - true for a descending sortpublic boolean getDescending()
public void init(Environment env, Instances structure)
env - the environment variables to usestructure - the structure of the instances that the rule will
opperate onpublic int compare(Sorter.InstanceHolder o1, Sorter.InstanceHolder o2)
compare in interface java.util.Comparator<Sorter.InstanceHolder>o1 - the first instanceo2 - the second instance