netkit.graph
Class Attribute

java.lang.Object
  extended by netkit.graph.Attribute
Direct Known Subclasses:
AttributeCategorical, AttributeContinuous, AttributeDiscrete, AttributeIgnore

public abstract class Attribute
extends java.lang.Object

This is the abstract parent of all Attribute classes. Each Attribute object represents one field with a string name and an enumerated type. Subclasses are used to specify the specific kinds of types and any polymorphic behavior.

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

Constructor Summary
protected Attribute(java.lang.String name, Type type)
          Subclasses should provide a public constructor that overrides this one.
 
Method Summary
abstract  java.lang.String formatForOutput(double value)
          Formats the supplied value from this attribute as a String for output.
 java.lang.String getName()
          Get the name of this Attribute.
 Type getType()
          Get the type of this Attribute.
abstract  double parseAndInsert(java.lang.String token)
          Parses the supplied string token for insertion into this attribute and converts the token into a double value.
 java.lang.String toString()
          Returns a String representation for this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Attribute

protected Attribute(java.lang.String name,
                    Type type)
Subclasses should provide a public constructor that overrides this one.

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

parseAndInsert

public abstract double parseAndInsert(java.lang.String token)
Parses the supplied string token for insertion into this attribute and converts the token into a double value. If the attribute subclass implementation requires keeping track of tokens, then subclasses may do so. Attribute values that may need to be unique must therefore be parsed only once.

Parameters:
token - the string value to parse.
Returns:
the token converted into an double as per the parsing rules of the subclass implementation.
Throws:
java.lang.RuntimeException - or an exception subclass if the token cannot be parsed by the attribute subclass or some other constraint is violated.

formatForOutput

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

Parameters:
value - a double to be converted into an output String.
Returns:
a String representing the supplied value.

getName

public final java.lang.String getName()
Get the name of this Attribute.

Returns:
the name of this Attribute.

getType

public final Type getType()
Get the type of this Attribute.

Returns:
the type of this Attribute.

toString

public final java.lang.String toString()
Returns a String representation for this object.

Overrides:
toString in class java.lang.Object
Returns:
a String representation for this object.