jBNC Toolbox

jbnc.dataset
Class AttributeSpecs

java.lang.Object
  extended byjbnc.dataset.AttributeSpecs

public final class AttributeSpecs
extends java.lang.Object

Describes a single attribute/feature in a data set.

Since:
June 1, 1999
Author:
Jarek Sacha
See Also:
Dataset, NamesReader, DatasetReader

Nested Class Summary
static class AttributeSpecs.AttributeException
          Exception specific to the AttributeSpecs class.
 
Constructor Summary
AttributeSpecs()
          By default created attribute with type IGNORE.
AttributeSpecs(java.lang.String name, AttributeType type)
          Can create attribute with type CONTINUOUS or IGNORE.
AttributeSpecs(java.lang.String name, int n)
          Creates a disctete attribute with n states (DISCRETE_N).
AttributeSpecs(java.lang.String name, java.lang.String[] states)
          Creates a DISCRETE attribute.
 
Method Summary
 java.lang.String getName()
          Get attribute name.
 java.lang.String getState(int index)
          Returns state name for a state with the given state index.
 int getState(java.lang.String name)
          Returns state index for a state with the given state name.
 java.lang.String[] getStates()
          Return states of a discrete attribute.
 AttributeType getType()
          Get attribute type.
 void setName(java.lang.String name)
          Set attribute name.
 void setStates(java.lang.String[] states)
          Set states of a discrete attribute.
 void setType(AttributeType type)
          Set attribute type.
 void setType(AttributeType type, int n)
          Set attribute type to DISCRETE_N and specify number of states n.
 java.lang.String toString()
          Description of the attribute type or list of attribute states (in type is DISCRETE).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AttributeSpecs

public AttributeSpecs()
By default created attribute with type IGNORE.


AttributeSpecs

public AttributeSpecs(java.lang.String name,
                      AttributeType type)
               throws AttributeSpecs.AttributeException
Can create attribute with type CONTINUOUS or IGNORE.

Parameters:
name - Name of the attribute.
type - Type of the attribute (CONTINUOUS or IGNORE).
Throws:
AttributeSpecs.AttributeException - Attribute type is neither CONTINUOUS nor IGNORE.

AttributeSpecs

public AttributeSpecs(java.lang.String name,
                      java.lang.String[] states)
Creates a DISCRETE attribute.

Parameters:
name - Name of the attribute.
states - States of the discrete attribute.

AttributeSpecs

public AttributeSpecs(java.lang.String name,
                      int n)
               throws AttributeSpecs.AttributeException
Creates a disctete attribute with n states (DISCRETE_N).

Parameters:
name - Name of the attribute.
n - Number of discrete values represented by the attribute (from 0 to n-1).
Throws:
AttributeSpecs.AttributeException - type is not equal to DISCRETE_N.
Method Detail

setName

public void setName(java.lang.String name)
Set attribute name.

Parameters:
name - The new Name value

setType

public void setType(AttributeType type)
Set attribute type.

Parameters:
type - The new Type value

setType

public void setType(AttributeType type,
                    int n)
             throws AttributeSpecs.AttributeException
Set attribute type to DISCRETE_N and specify number of states n.

Parameters:
type - Attriute byte type. Has to be DESCRETE_N.
n - Number of discrete values represented by the attribute (from 0 to n-1).
Throws:
AttributeSpecs.AttributeException - type is not equal to DISCRETE_N.
AttributeSpecs.AttributeException - n is less then one.

setStates

public void setStates(java.lang.String[] states)
               throws AttributeSpecs.AttributeException
Set states of a discrete attribute. Throws exception of the attribute is not discrete.

Parameters:
states - The new States value
Throws:
AttributeSpecs.AttributeException - Description of Exception

getName

public java.lang.String getName()
Get attribute name.

Returns:
The Name value

getType

public AttributeType getType()
Get attribute type.

Returns:
The Type value

getState

public java.lang.String getState(int index)
                          throws AttributeSpecs.AttributeException
Returns state name for a state with the given state index. Used for discrete attributes.

Parameters:
index - Description of Parameter
Returns:
The State value
Throws:
AttributeSpecs.AttributeException - Description of Exception

getState

public int getState(java.lang.String name)
             throws AttributeSpecs.AttributeException
Returns state index for a state with the given state name. Used for discrete attributes.

Parameters:
name - Description of Parameter
Returns:
The State value
Throws:
AttributeSpecs.AttributeException - Description of Exception

getStates

public java.lang.String[] getStates()
Return states of a discrete attribute.

Returns:
The States value

toString

public java.lang.String toString()
Description of the attribute type or list of attribute states (in type is DISCRETE).

Returns:
Description of the Returned Value

SourceForge.net Logo