public class NominalAttribute extends Attribute
Modifier and Type | Field and Description |
---|---|
(package private) java.util.ArrayList<java.lang.String> |
domain
a list of strings for the domain of nominal attributes
|
Constructor and Description |
---|
NominalAttribute()
Default constructor.
|
NominalAttribute(java.lang.String name)
Explicit constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addValue(java.lang.String value)
Adds a new nominal value to the domain of this nominal attribute.
|
int |
getIndex(java.lang.String value)
Returns the index of the specified value index for this nominal
attribute.
|
int |
getSize()
Gets the size of this nominal attribute's domain.
|
java.lang.String |
getValue(int index)
Returns the value of this nominal attribute at the specified index.
|
static void |
main(java.lang.String[] args)
A main method for testing.
|
java.lang.String |
toString()
Returns a string representation of this NominalAttribute.
|
java.util.ArrayList<java.lang.String> domain
public NominalAttribute()
public NominalAttribute(java.lang.String name)
name
- the name of this data setpublic void addValue(java.lang.String value) throws java.lang.Exception
value
- the attribute's new domain valuejava.lang.Exception
- if the value can not be addedpublic int getSize()
public java.lang.String getValue(int index) throws java.lang.Exception
index
- the attribute value's indexjava.lang.Exception
- if the index is out of boundspublic int getIndex(java.lang.String value) throws java.lang.Exception
value
- the attribute's valuejava.lang.Exception
- if the value is illegalpublic java.lang.String toString()
public static void main(java.lang.String[] args)