netkit.graph
Class AttributeDiscrete

java.lang.Object
  extended by netkit.graph.Attribute
      extended by netkit.graph.AttributeDiscrete

public final class AttributeDiscrete
extends Attribute

This class handles attributes that are of type DISCRETE. DISCRETE types can have integer numerical values and are represented internally as java double types. This class is immutable.

Author:
Kaveh R. Ghazi
See Also:
Attributes, SchemaReader

Constructor Summary
AttributeDiscrete(java.lang.String name)
          The constructor must be provided the name for this attribute.
 
Method Summary
 java.lang.String formatForOutput(double value)
          Formats the supplied value from this attribute as a String for output.
 double parseAndInsert(java.lang.String token)
          Parses the supplied string token for insertion into this attribute and converts the token into a double value; a "?" token results in NaN.
 
Methods inherited from class netkit.graph.Attribute
getName, getType, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AttributeDiscrete

public AttributeDiscrete(java.lang.String name)
The constructor must be provided the name for this attribute.

Parameters:
name - a String representing the name of this attribute.
Method Detail

parseAndInsert

public double parseAndInsert(java.lang.String token)
Parses the supplied string token for insertion into this attribute and converts the token into a double value; a "?" token results in NaN.

Specified by:
parseAndInsert in class Attribute
Parameters:
token - the string value to parse.
Returns:
the token converted into an double.
Throws:
java.lang.NumberFormatException - if the token does not contain a parsable integer.

formatForOutput

public java.lang.String formatForOutput(double value)
Description copied from class: Attribute
Formats the supplied value from this attribute as a String for output. Subclasses will supply their own mechanism for conversion.

Specified by:
formatForOutput in class Attribute
Parameters:
value - a double to be converted into an output String.
Returns:
a String representing the supplied value.