public class M5Attribute
extends java.lang.Object
implements java.io.Serializable
Three attribute types are supported:
Modifier and Type | Field and Description |
---|---|
static int |
NOMINAL
Constant set for nominal attributes.
|
static int |
NUMERIC
Constant set for numeric attributes.
|
static int |
STRING
Constant set for attributes with string values.
|
Constructor and Description |
---|
M5Attribute(java.lang.String attributeName)
Constructor for a numeric attribute.
|
M5Attribute(java.lang.String attributeName,
M5Vector attributeValues)
Constructor for nominal attributes and string attributes.
|
Modifier and Type | Method and Description |
---|---|
int |
addStringValue(M5Attribute src,
int index)
Adds a string value to the list of valid strings for attributes
of type STRING and returns the index of the string.
|
int |
addStringValue(java.lang.String value)
Adds a string value to the list of valid strings for attributes
of type STRING and returns the index of the string.
|
java.lang.Object |
copy()
Produces a shallow copy of this attribute.
|
java.util.Enumeration |
enumerateValues()
Returns an enumeration of all the attribute's values if
the attribute is nominal or a string, null otherwise.
|
boolean |
equals(java.lang.Object other)
Tests if given attribute is equal to this attribute.
|
int |
index()
Returns the index of this attribute.
|
int |
indexOfValue(java.lang.String value)
Returns the index of a given attribute value.
|
boolean |
isNominal()
Test if the attribute is nominal.
|
boolean |
isNumeric()
Tests if the attribute is numeric.
|
boolean |
isString()
Tests if the attribute is a string.
|
static void |
main(java.lang.String[] ops)
Simple main method for testing this class.
|
java.lang.String |
name()
Returns the attribute's name.
|
int |
numValues()
Returns the number of attribute values.
|
java.lang.String |
toString()
Returns a description of this attribute in ARFF format.
|
int |
type()
Returns the attribute's type as an integer.
|
java.lang.String |
value(int valIndex)
Returns a value of a nominal or string attribute.
|
public static final int NUMERIC
public static final int NOMINAL
public static final int STRING
public M5Attribute(java.lang.String attributeName)
attributeName
- the name for the attributepublic M5Attribute(java.lang.String attributeName, M5Vector attributeValues)
attributeName
- the name for the attributeattributeValues
- a vector of strings denoting the
attribute values. Null if the attribute is a string attribute.public java.lang.Object copy()
public final java.util.Enumeration enumerateValues()
public final boolean equals(java.lang.Object other)
equals
in class java.lang.Object
other
- the Object to be compared to this attributepublic final int index()
public final int indexOfValue(java.lang.String value)
value
- the value for which the index is to be returnedpublic final boolean isNominal()
public final boolean isNumeric()
public final boolean isString()
public final java.lang.String name()
public final int numValues()
public final java.lang.String toString()
toString
in class java.lang.Object
public final int type()
public final java.lang.String value(int valIndex)
valIndex
- the value's indexpublic int addStringValue(java.lang.String value)
value
- The string value to addpublic int addStringValue(M5Attribute src, int index)
src
- The Attribute containing the string value to add.index
- the index of the string value in the source attribute.public static void main(java.lang.String[] ops)
ops
- main args.