Class NominalAttribute
- java.lang.Object
-
- Attribute
-
- NominalAttribute
-
public class NominalAttribute extends Attribute
Stores information for a nominal attribute. A nominal attribute has has a name and a domain.
-
-
Constructor Summary
Constructors Constructor Description NominalAttribute()
Default constructor.NominalAttribute(java.lang.String name)
Explicit constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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.java.lang.String
getValue(int index)
Returns the value of this nominal attribute at the specified index.static void
main(java.lang.String[] args)
int
size()
Gets the size of this nominal attribute's domain.java.lang.String
toString()
Returns a string representation of this NominalAttribute.boolean
validValue(java.lang.String value)
Returns whether the value is valid for a nominal attribute
-
-
-
Method Detail
-
addValue
public void addValue(java.lang.String value)
Adds a new nominal value to the domain of this nominal attribute.- Parameters:
value
- the attribute's new domain value
-
size
public int size()
Gets the size of this nominal attribute's domain.
-
getValue
public java.lang.String getValue(int index)
Returns the value of this nominal attribute at the specified index.- Parameters:
index
- the attribute value's index- Returns:
- the attribute value at the specified index
-
getIndex
public int getIndex(java.lang.String value) throws java.lang.Exception
Returns the index of the specified value index for this nominal attribute.- Parameters:
value
- the attribute's value- Returns:
- the index of the specified value
- Throws:
java.lang.Exception
- if the value is not in the domain
-
toString
public java.lang.String toString()
Returns a string representation of this NominalAttribute.
-
validValue
public boolean validValue(java.lang.String value)
Returns whether the value is valid for a nominal attribute- Parameters:
value
- the value for testing- Returns:
- true if the value is valid; false otherwise
-
main
public static void main(java.lang.String[] args)
-
-