public class Attributes
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private java.util.ArrayList<Attribute> |
attributes
a list of attributes
|
private int |
classIndex
stores the position of the class label
|
private boolean |
hasNumericAttributes
a flag indicating that the data set has one or more numeric attributes
|
| Constructor and Description |
|---|
Attributes()
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(Attribute attribute)
Adds a new attribute to this set of attributes.
|
Attribute |
get(int i)
Returns the ith attribute in this set of attributes.
|
Attribute |
getClassAttribute()
Returns the class attribute.
|
int |
getClassIndex()
Returns the index of the class label.
|
boolean |
getHasNumericAttributes()
Returns true if this set of attributes has one or more numeric attributes;
returns false otherwise.
|
int |
getIndex(java.lang.String name)
Returns the attribute's index.
|
static void |
main(java.lang.String[] args)
A main method for testing.
|
void |
parse(java.util.Scanner scanner)
Parses the attribute declarations in the specified scanner.
|
void |
setClassIndex(int classIndex)
Sets the class index for this set of attributes.
|
int |
size()
Returns the number of attributes.
|
java.lang.String |
toString()
Returns a string representation of this Attributes object.
|
private java.util.ArrayList<Attribute> attributes
private boolean hasNumericAttributes
private int classIndex
public void add(Attribute attribute)
attribute - the attribute's namepublic int getClassIndex()
public boolean getHasNumericAttributes()
public Attribute get(int i)
i - the index of the specified attributepublic Attribute getClassAttribute()
public int getIndex(java.lang.String name)
throws java.lang.Exception
name - the attribute's namejava.lang.Exception - if the attribute does not existpublic int size()
public void parse(java.util.Scanner scanner)
throws java.lang.Exception
scanner - a Scanner containing the data set's tokensjava.lang.Exception - if a parse exception occurspublic void setClassIndex(int classIndex)
throws java.lang.Exception
classIndex - the new class indexjava.lang.Exception - if the class index is out of of boundspublic java.lang.String toString()
toString in class java.lang.Objectpublic static void main(java.lang.String[] args)
args - command-line arguments