public abstract class AbstractInstance extends java.lang.Object implements Instance, java.io.Serializable, RevisionHandler
Modifier and Type | Field and Description |
---|---|
static int |
s_numericAfterDecimalPoint
Default max number of digits after the decimal point for numeric values
|
Constructor and Description |
---|
AbstractInstance() |
Modifier and Type | Method and Description |
---|---|
Attribute |
attribute(int index)
Returns the attribute with the given index.
|
Attribute |
attributeSparse(int indexOfIndex)
Returns the attribute with the given index in the sparse representation.
|
Attribute |
classAttribute()
Returns class attribute.
|
int |
classIndex()
Returns the class attribute's index.
|
boolean |
classIsMissing()
Tests if an instance's class is missing.
|
double |
classValue()
Returns an instance's class value in internal format.
|
Instances |
dataset()
Returns the dataset this instance has access to.
|
void |
deleteAttributeAt(int position)
Deletes an attribute at the given position (0 to numAttributes() - 1).
|
java.util.Enumeration<Attribute> |
enumerateAttributes()
Returns an enumeration of all the attributes.
|
boolean |
equalHeaders(Instance inst)
Tests if the headers of two instances are equivalent.
|
java.lang.String |
equalHeadersMsg(Instance inst)
Checks if the headers of two instances are equivalent.
|
java.lang.String |
getRevision()
Returns the revision string.
|
boolean |
hasMissingValue()
Tests whether an instance has a missing value.
|
void |
insertAttributeAt(int position)
Inserts an attribute at the given position (0 to numAttributes()).
|
boolean |
isMissing(Attribute att)
Tests if a specific value is "missing".
|
boolean |
isMissing(int attIndex)
Tests if a specific value is "missing".
|
boolean |
isMissingSparse(int indexOfIndex)
Tests if a specific value is "missing", given an index in the sparse
representation.
|
int |
numClasses()
Returns the number of class labels.
|
Instances |
relationalValue(Attribute att)
Returns the relational value of a relational attribute.
|
Instances |
relationalValue(int attIndex)
Returns the relational value of a relational attribute.
|
void |
setClassMissing()
Sets the class value of an instance to be "missing".
|
void |
setClassValue(double value)
Sets the class value of an instance to the given value (internal
floating-point format).
|
void |
setClassValue(java.lang.String value)
Sets the class value of an instance to the given value.
|
void |
setDataset(Instances instances)
Sets the reference to the dataset.
|
void |
setMissing(Attribute att)
Sets a specific value to be "missing".
|
void |
setMissing(int attIndex)
Sets a specific value to be "missing".
|
void |
setValue(Attribute att,
double value)
Sets a specific value in the instance to the given value (internal
floating-point format).
|
void |
setValue(Attribute att,
java.lang.String value)
Sets a value of an nominal or string attribute to the given value.
|
void |
setValue(int attIndex,
java.lang.String value)
Sets a value of a nominal or string attribute to the given value.
|
void |
setWeight(double weight)
Sets the weight of an instance.
|
java.lang.String |
stringValue(Attribute att)
Returns the value of a nominal, string, date, or relational attribute for
the instance as a string.
|
java.lang.String |
stringValue(int attIndex)
Returns the value of a nominal, string, date, or relational attribute for
the instance as a string.
|
java.lang.String |
toString()
Returns the description of one instance.
|
java.lang.String |
toString(Attribute att)
Returns the description of one value of the instance as a string.
|
java.lang.String |
toString(Attribute att,
int afterDecimalPoint)
Returns the description of one value of the instance as a string.
|
java.lang.String |
toString(int attIndex)
Returns the description of one value of the instance as a string.
|
java.lang.String |
toString(int attIndex,
int afterDecimalPoint)
Returns the description of one value of the instance as a string.
|
java.lang.String |
toStringMaxDecimalDigits(int afterDecimalPoint)
Returns the description of one instance with any numeric values printed at
the supplied maximum number of decimal places.
|
double |
value(Attribute att)
Returns an instance's attribute value in internal format.
|
double |
valueSparse(int indexOfIndex)
Returns an instance's attribute value in internal format, given an index in
the sparse representation.
|
double |
weight()
Returns the instance's weight.
|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
copy, index, mergeInstance, numAttributes, numValues, replaceMissingValues, setValue, setValueSparse, toDoubleArray, toStringNoWeight, toStringNoWeight, value
public static int s_numericAfterDecimalPoint
public Attribute attribute(int index)
attribute
in interface Instance
index
- the attribute's indexUnassignedDatasetException
- if instance doesn't have access to a
datasetpublic Attribute attributeSparse(int indexOfIndex)
attributeSparse
in interface Instance
indexOfIndex
- the index of the attribute's indexUnassignedDatasetException
- if instance doesn't have access to a
datasetpublic Attribute classAttribute()
classAttribute
in interface Instance
UnassignedDatasetException
- if the class is not set or the instance
doesn't have access to a datasetpublic int classIndex()
classIndex
in interface Instance
UnassignedDatasetException
- if instance doesn't have access to a
datasetpublic boolean classIsMissing()
classIsMissing
in interface Instance
UnassignedClassException
- if the class is not set or the instance
doesn't have access to a datasetpublic double classValue()
classValue
in interface Instance
UnassignedClassException
- if the class is not set or the instance
doesn't have access to a datasetpublic Instances dataset()
public void deleteAttributeAt(int position)
deleteAttributeAt
in interface Instance
position
- the attribute's positionjava.lang.RuntimeException
- if the instance has access to a datasetpublic java.util.Enumeration<Attribute> enumerateAttributes()
enumerateAttributes
in interface Instance
UnassignedDatasetException
- if the instance doesn't have access to a
datasetpublic boolean equalHeaders(Instance inst)
equalHeaders
in interface Instance
inst
- another instanceUnassignedDatasetException
- if instance doesn't have access to any
datasetpublic java.lang.String equalHeadersMsg(Instance inst)
equalHeadersMsg
in interface Instance
dataset
- another instancepublic boolean hasMissingValue()
hasMissingValue
in interface Instance
UnassignedDatasetException
- if instance doesn't have access to any
datasetpublic void insertAttributeAt(int position)
insertAttributeAt
in interface Instance
position
- the attribute's positionjava.lang.RuntimeException
- if the instance has accesss to a datasetjava.lang.IllegalArgumentException
- if the position is out of rangepublic boolean isMissing(int attIndex)
public boolean isMissingSparse(int indexOfIndex)
isMissingSparse
in interface Instance
indexOfIndex
- the index of the attribute's indexpublic boolean isMissing(Attribute att)
public int numClasses()
numClasses
in interface Instance
UnassignedDatasetException
- if instance doesn't have access to any
datasetpublic void setClassMissing()
setClassMissing
in interface Instance
UnassignedClassException
- if the class is not setUnassignedDatasetException
- if the instance doesn't have access to a
datasetpublic void setClassValue(double value)
setClassValue
in interface Instance
value
- the new attribute value (If the corresponding attribute is
nominal (or a string) then this is the new value's index as a
double).UnassignedClassException
- if the class is not setUnaddignedDatasetException
- if the instance doesn't have access to a
datasetpublic final void setClassValue(java.lang.String value)
setClassValue
in interface Instance
value
- the new class value (If the class is a string attribute and
the value can't be found, the value is added to the attribute).UnassignedClassException
- if the class is not setUnassignedDatasetException
- if the dataset is not setjava.lang.IllegalArgumentException
- if the attribute is not nominal or a
string, or the value couldn't be found for a nominal attributepublic final void setDataset(Instances instances)
setDataset
in interface Instance
instances
- the reference to the datasetpublic final void setMissing(int attIndex)
setMissing
in interface Instance
attIndex
- the attribute's indexpublic final void setMissing(Attribute att)
setMissing
in interface Instance
att
- the attributepublic final void setValue(int attIndex, java.lang.String value)
setValue
in interface Instance
attIndex
- the attribute's indexvalue
- the new attribute value (If the attribute is a string
attribute and the value can't be found, the value is added to the
attribute).UnassignedDatasetException
- if the dataset is not setjava.lang.IllegalArgumentException
- if the selected attribute is not nominal
or a string, or the supplied value couldn't be found for a
nominal attributepublic final void setValue(Attribute att, double value)
public final void setValue(Attribute att, java.lang.String value)
setValue
in interface Instance
att
- the attributevalue
- the new attribute value (If the attribute is a string
attribute and the value can't be found, the value is added to the
attribute).java.lang.IllegalArgumentException
- if the the attribute is not nominal or a
string, or the value couldn't be found for a nominal attributepublic final void setWeight(double weight)
public final Instances relationalValue(int attIndex)
relationalValue
in interface Instance
attIndex
- the attribute's indexjava.lang.IllegalArgumentException
- if the attribute is not a relation-valued
attributeUnassignedDatasetException
- if the instance doesn't belong to a
dataset.public final Instances relationalValue(Attribute att)
relationalValue
in interface Instance
att
- the attributejava.lang.IllegalArgumentException
- if the attribute is not a relation-valued
attributeUnassignedDatasetException
- if the instance doesn't belong to a
dataset.public final java.lang.String stringValue(int attIndex)
stringValue
in interface Instance
attIndex
- the attribute's indexjava.lang.IllegalArgumentException
- if the attribute is not a nominal, string,
date, or relation-valued attribute.UnassignedDatasetException
- if the instance doesn't belong to a
dataset.public final java.lang.String stringValue(Attribute att)
stringValue
in interface Instance
att
- the attributejava.lang.IllegalArgumentException
- if the attribute is not a nominal, string,
date, or relation-valued attribute.UnassignedDatasetException
- if the instance doesn't belong to a
dataset.public final java.lang.String toStringMaxDecimalDigits(int afterDecimalPoint)
toStringMaxDecimalDigits
in interface Instance
afterDecimalPoint
- the maximum number of digits permitted after the
decimal point for a numeric valuepublic java.lang.String toString()
toString
in class java.lang.Object
public final java.lang.String toString(int attIndex)
public final java.lang.String toString(int attIndex, int afterDecimalPoint)
public final java.lang.String toString(Attribute att)
public final java.lang.String toString(Attribute att, int afterDecimalPoint)
public double value(Attribute att)
public double valueSparse(int indexOfIndex)
valueSparse
in interface Instance
indexOfIndex
- the index of the attribute's indexpublic final double weight()
public java.lang.String getRevision()
getRevision
in interface RevisionHandler