org.omegahat.DataStructures.Data
Class FactorVariable

java.lang.Object
  |
  +--org.omegahat.DataStructures.Data.AbstractVariable
        |
        +--org.omegahat.DataStructures.Data.FactorVariable
All Implemented Interfaces:
DataVariableInt, FactorInt, java.io.Serializable, VariableInt

public class FactorVariable
extends AbstractVariable
implements FactorInt, java.io.Serializable

An unordered factor variable that has a set of levels and observed values that are indices into this set to identify that record's level/value.

See Also:
Serialized Form

Field Summary
protected  int[] levelIndices
           
protected  FactorLevelSetInt levels
           
protected  java.lang.Object[] values
           
 
Fields inherited from class org.omegahat.DataStructures.Data.AbstractVariable
metaData, name
 
Constructor Summary
FactorVariable()
           
FactorVariable(FactorVariable var)
           
FactorVariable(int num)
           
FactorVariable(java.lang.Object[] str)
           
FactorVariable(java.lang.Object[] str, int num)
           
FactorVariable(java.lang.Object[] str, int num, java.util.Hashtable metaData)
           
 
Method Summary
 void add(double value, int which)
           
 void add(int value, int which)
           
 void add(java.lang.Object value, int which)
           
 java.lang.Object asArray()
           
 java.lang.Object asArrayCopy()
           
protected  java.lang.Object[] computeValues()
           
 int getSize()
           
 double[] getValues()
           
 long[] indicesForLevel(java.lang.Object level)
          Get the indices of the observations associated with the given level.
 java.lang.Object[] labels()
           
 FactorLevelSetInt levels()
          Return an element containing the different levels used by this variable.
 FactorLevelSetInt levels(FactorLevelSetInt lev)
           
 FactorLevelSetInt levels(java.lang.Object value)
           
 FactorLevelSetInt levels(java.lang.String[] els)
           
 FactorLevelSetInt levels(java.util.Vector v)
           
 int numLevels()
           
 long numObservations()
          Return the length or number of records in this VariableInt.
 java.lang.String toString()
           
 java.lang.Object[] toStringArray()
           
 java.lang.Object value(int i)
           
 java.lang.Object[] values()
           
 VariableInt values(int[] ind)
          Get a Variable consisting of the specified elements.
 
Methods inherited from class org.omegahat.DataStructures.Data.AbstractVariable
getName, metaData, metaData, read, setName, value, values
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.omegahat.DataStructures.Data.VariableInt
getName, metaData, read, setName, value, values
 

Field Detail

levels

protected FactorLevelSetInt levels

levelIndices

protected int[] levelIndices

values

protected java.lang.Object[] values
Constructor Detail

FactorVariable

public FactorVariable()

FactorVariable

public FactorVariable(int num)

FactorVariable

public FactorVariable(java.lang.Object[] str)

FactorVariable

public FactorVariable(java.lang.Object[] str,
                      int num)

FactorVariable

public FactorVariable(java.lang.Object[] str,
                      int num,
                      java.util.Hashtable metaData)

FactorVariable

public FactorVariable(FactorVariable var)
Method Detail

labels

public java.lang.Object[] labels()

levels

public FactorLevelSetInt levels()
Description copied from interface: FactorInt
Return an element containing the different levels used by this variable.
Specified by:
levels in interface FactorInt

levels

public FactorLevelSetInt levels(FactorLevelSetInt lev)

levels

public FactorLevelSetInt levels(java.lang.String[] els)

levels

public FactorLevelSetInt levels(java.lang.Object value)

levels

public FactorLevelSetInt levels(java.util.Vector v)

numLevels

public int numLevels()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getSize

public int getSize()

values

public java.lang.Object[] values()
Specified by:
values in interface FactorInt

computeValues

protected java.lang.Object[] computeValues()

value

public java.lang.Object value(int i)

asArray

public java.lang.Object asArray()

asArrayCopy

public java.lang.Object asArrayCopy()

values

public VariableInt values(int[] ind)
Description copied from interface: VariableInt
Get a Variable consisting of the specified elements.
Specified by:
values in interface VariableInt
Overrides:
values in class AbstractVariable

toStringArray

public java.lang.Object[] toStringArray()

add

public void add(java.lang.Object value,
                int which)
Specified by:
add in interface VariableInt
Overrides:
add in class AbstractVariable

add

public void add(double value,
                int which)
Specified by:
add in interface VariableInt
Overrides:
add in class AbstractVariable

add

public void add(int value,
                int which)

numObservations

public long numObservations()
Description copied from interface: VariableInt
Return the length or number of records in this VariableInt.
Specified by:
numObservations in interface VariableInt

getValues

public double[] getValues()

indicesForLevel

public long[] indicesForLevel(java.lang.Object level)
Description copied from interface: FactorInt
Get the indices of the observations associated with the given level.
Specified by:
indicesForLevel in interface FactorInt