shared
Class AttrInfo

java.lang.Object
  |
  +--shared.AttrInfo
Direct Known Subclasses:
NominalAttrInfo, RealAttrInfo

public abstract class AttrInfo
extends java.lang.Object
implements java.lang.Cloneable

The AttrInfo class allows giving attribute names, types, and a position in the instance array. This implementation assumes the value of UNKNOWN_REAL_VAL is never used for a known real value. Given k discrete categories, they will be mapped into integers in the range [0..k-1]. Globals.UNKNOWN_CATEGORY_VAL is used for unknown/undefined.


Field Summary
 java.lang.String attrName
          The name of this attribute.
 byte attrType
          The type of this attribute.
static byte boundedReal
          Value for BoundedReal attribute type.
static byte internalDisjunction
          Value for InternalDisjunction attribute type.
static byte linearNominal
          Value for LinearNominal attribute type.
static byte nominal
          Value for Nominal attribute type.
static byte real
          Value for Real attribute type.
static byte treeStructured
          Value for TreeStructured attribute type.
static byte unknown
          Value for Unknown attribute type.
static java.lang.String UNKNOWN_VAL_STR
          The String to be displayed for unknown values.
static byte userInternalDisjunction
          Value for UserInternalDisjunction attribute type.
static byte userLinearNominal
          Value for UserLinearNominal attribute type.
static byte userNominal
          Value for UserNominal attribute type.
static byte userReal
          Value for UserReal attribute type.
static byte userTreeStructured
          Value for UserTreeStructured attribute type.
 
Constructor Summary
AttrInfo(AttrInfo source)
          Copy constructor.
AttrInfo(java.lang.String aName, byte aType)
          Constructor.
 
Method Summary
static java.lang.String attr_type_to_string(byte t)
          Returns a String value of the type of attribute the specified byte represents.
abstract  java.lang.String attrValue_to_string(AttrValue a)
          Returns a String representing the value for the specified AttrValue.
 boolean can_cast_to_nominal()
          Checks if this attribute can be considered a nominal value attribute.
 boolean can_cast_to_real()
          Checks if this attribute can be considered a real value attribute.
 NominalAttrInfo cast_to_nominal()
          Determines if this AttrInfo can be considered a Nominla AttrInfo and creates a new one if possible.
 RealAttrInfo cast_to_real()
          Determines if this AttrInfo can be considered a RealAttrInfo and creates a new one if possible.
abstract  void check_in_range(AttrValue val)
          Checks if the specified AttrValue is with in the range indicated in the Globals file.
 java.lang.Object clone()
          Clones this AttrInfo.
 void display_attr_values()
          Displays the values for the attribute represented by this object to the specified Writer.
 void display_attr_values(java.io.Writer stream)
          Displays the values for the attribute represented by this object to the specified Writer.
abstract  void display_attr_values(java.io.Writer stream, boolean protectChars)
          Displays the values for the attribute represented by this object to the specified Writer.
protected  boolean equal_shallow(AttrInfo info, boolean fatalOnFalse)
          Compares attrName, attrType, and attrNum of this AttrInfo to the specified AttrInfo.
abstract  boolean equal_value(AttrValue i_attrvalue1, AttrValue i_attrvalue2)
          Determines if the specified AttrValues are equal.
 boolean get_ignore()
          Checks if this attribute should be ignored during induction.
 int get_nominal_val(AttrValue AV)
          Always returns zero and displays an error message.
 double get_real_val(AttrValue av)
          Always returns zero and displays an error message.
 boolean is_linear()
          Checks if this AttrInfo object has linear values.
abstract  boolean is_unknown(AttrValue v)
          Checks if the specified AttrValue is an unknown value.
 java.lang.String name()
          Returns the name of this attribute.
static java.lang.String protect_chars(java.lang.String str)
          Protect special characters by prefixing them with \.
 AttrValue read_attr_value(java.io.BufferedReader r, boolean i, FileSchema f)
          Reads the value for the attribute from the BufferedReader specified.
 void set_ignore(boolean ig)
          Sets wether this attribute should be ignored.
 void set_nominal_string(AttrValue a, java.lang.String s, boolean b)
          Sets the nominal name for this AttrInfo.
 void set_nominal_val(AttrValue a, int v)
          Sets the nominal value for this AttrInfo.
 void set_real_val(AttrValue av, double v)
          Sets the real value for this AttrInfo.
abstract  void set_unknown(AttrValue a)
          Sets the value for the specified AttrValue to the unknown value for that attribute type.
 byte type()
          Returns the type of this attribute.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

attrName

public java.lang.String attrName
The name of this attribute.

attrType

public byte attrType
The type of this attribute.

unknown

public static final byte unknown
Value for Unknown attribute type.

real

public static final byte real
Value for Real attribute type.

boundedReal

public static final byte boundedReal
Value for BoundedReal attribute type.

nominal

public static final byte nominal
Value for Nominal attribute type.

linearNominal

public static final byte linearNominal
Value for LinearNominal attribute type.

treeStructured

public static final byte treeStructured
Value for TreeStructured attribute type.

internalDisjunction

public static final byte internalDisjunction
Value for InternalDisjunction attribute type.

userReal

public static final byte userReal
Value for UserReal attribute type.

userNominal

public static final byte userNominal
Value for UserNominal attribute type.

userLinearNominal

public static final byte userLinearNominal
Value for UserLinearNominal attribute type.

userTreeStructured

public static final byte userTreeStructured
Value for UserTreeStructured attribute type.

userInternalDisjunction

public static final byte userInternalDisjunction
Value for UserInternalDisjunction attribute type.

UNKNOWN_VAL_STR

public static final java.lang.String UNKNOWN_VAL_STR
The String to be displayed for unknown values.
Constructor Detail

AttrInfo

public AttrInfo(java.lang.String aName,
                byte aType)
Constructor.
Parameters:
aName - The name of the attribute.
aType - The type of the attribute.

AttrInfo

public AttrInfo(AttrInfo source)
Copy constructor.
Parameters:
source - The AttrInfo to be copied.
Method Detail

is_linear

public boolean is_linear()
Checks if this AttrInfo object has linear values. Always returns FALSE.
Returns:
Always FALSE.

is_unknown

public abstract boolean is_unknown(AttrValue v)
Checks if the specified AttrValue is an unknown value.
Parameters:
v - The specified AttrValue containing the value to be checked.
Returns:
TRUE if this AttrValue instance is an unknown value, FALSE otherwise.

check_in_range

public abstract void check_in_range(AttrValue val)
Checks if the specified AttrValue is with in the range indicated in the Globals file.
Parameters:
val - The AttrValue being checked.

attr_type_to_string

public static java.lang.String attr_type_to_string(byte t)
Returns a String value of the type of attribute the specified byte represents.
Parameters:
t - The byte value to be checked.
Returns:
A String with the name of the type of data represented by this byte value.

set_unknown

public abstract void set_unknown(AttrValue a)
Sets the value for the specified AttrValue to the unknown value for that attribute type.
Parameters:
a - The value to be changed.

attrValue_to_string

public abstract java.lang.String attrValue_to_string(AttrValue a)
Returns a String representing the value for the specified AttrValue.
Parameters:
a - The AttrValue containing the value.
Returns:
A String representing the value for the specified AttrValue.

get_real_val

public double get_real_val(AttrValue av)
Always returns zero and displays an error message. AttrInfo does not have methods specific to different data types except as an necessity. Not meant for use with AttrInfo base class.
Parameters:
av - The value of the attribute.
Returns:
Always zero.

set_real_val

public void set_real_val(AttrValue av,
                         double v)
Sets the real value for this AttrInfo. Does nothing for the AttrInfo base class. Not meant for use with AttrInfo base class.
Parameters:
av - The AttrValue where the new value is to be stored.
v - The new value to be stored.

set_nominal_string

public void set_nominal_string(AttrValue a,
                               java.lang.String s,
                               boolean b)
Sets the nominal name for this AttrInfo. Does nothing for the AttrInfo base class.
Parameters:
a - The AttrValue where the new value is to be stored.
s - The new value to be stored.
b - A boolean value.

set_nominal_val

public void set_nominal_val(AttrValue a,
                            int v)
Sets the nominal value for this AttrInfo. Does nothing for the AttrInfo base class. Not meant for use with AttrInfo base class.
Parameters:
a - The AttrValue where the new value is to be stored.
v - The new value to be stored.

get_ignore

public boolean get_ignore()
Checks if this attribute should be ignored during induction.
Returns:
TRUE if this attribute should be ignored, FALSE otherwise.

read_attr_value

public AttrValue read_attr_value(java.io.BufferedReader r,
                                 boolean i,
                                 FileSchema f)
Reads the value for the attribute from the BufferedReader specified.
Parameters:
r - The specified BufferedReader to be read from.
i - TRUE if this value is for a test Instance, FALSE otherwise.
f - The FileSchema of the file being read.
Returns:
The attribute value read from the BufferedReader.

equal_shallow

protected boolean equal_shallow(AttrInfo info,
                                boolean fatalOnFalse)
Compares attrName, attrType, and attrNum of this AttrInfo to the specified AttrInfo.
Parameters:
info - The AttrInfo to be compared to.
fatalOnFalse - TRUE if an Error message should be displayed if these AttrInfos are not equal, FALSE otherwise.
Returns:
TRUE if attrName, attrType, and attrNum are equal, FALSE otherwise.

type

public byte type()
Returns the type of this attribute.
Returns:
A byte representing the type of this attribute.

name

public java.lang.String name()
Returns the name of this attribute.
Returns:
A String object with the name of this attribute.

set_ignore

public void set_ignore(boolean ig)
Sets wether this attribute should be ignored.
Parameters:
ig - TRUE if this attribute should be ignored.

can_cast_to_real

public boolean can_cast_to_real()
Checks if this attribute can be considered a real value attribute.
Returns:
Always FALSE for this class.

can_cast_to_nominal

public boolean can_cast_to_nominal()
Checks if this attribute can be considered a nominal value attribute.
Returns:
Always FALSE for this class.

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones this AttrInfo.
Overrides:
clone in class java.lang.Object
Returns:
The new AttrInfo cloned.
Throws:
java.lang.CloneNotSupportedException - Thrown if cloning is not possible.

cast_to_real

public RealAttrInfo cast_to_real()
Determines if this AttrInfo can be considered a RealAttrInfo and creates a new one if possible. For AttrInfo, this is not possible.
Returns:
The RealAttrInfo containing the information for this AttrInfo.

cast_to_nominal

public NominalAttrInfo cast_to_nominal()
Determines if this AttrInfo can be considered a Nominla AttrInfo and creates a new one if possible. For AttrInfo, this is not possible.
Returns:
The NominalAttrInfo containing the information for this AttrInfo.

get_nominal_val

public int get_nominal_val(AttrValue AV)
Always returns zero and displays an error message. AttrInfo does not have methods specific to different data types except as an necessity. Not meant for use with AttrInfo base class.
Parameters:
AV - The value of the attribute.
Returns:
Always zero.

equal_value

public abstract boolean equal_value(AttrValue i_attrvalue1,
                                    AttrValue i_attrvalue2)
Determines if the specified AttrValues are equal.
Parameters:
i_attrvalue1 - An AttrValue to be compared.
i_attrvalue2 - An AttrValue to be compared.
Returns:
TRUE if the specified AttrValues are equal, FALSE otherwise.

display_attr_values

public abstract void display_attr_values(java.io.Writer stream,
                                         boolean protectChars)
Displays the values for the attribute represented by this object to the specified Writer.
Parameters:
stream - The Writer to which the values will be displayed.
protectChars - TRUE if the '/' and '.' characters should be preceeded by a '/' character, FALSE otherwise.

display_attr_values

public void display_attr_values()
Displays the values for the attribute represented by this object to the specified Writer. Writes to Globals.Mcout and does not protect characters by default.

display_attr_values

public void display_attr_values(java.io.Writer stream)
Displays the values for the attribute represented by this object to the specified Writer. Does not protect characters by default.
Parameters:
stream - The Writer to which the values will be displayed.

protect_chars

public static java.lang.String protect_chars(java.lang.String str)
Protect special characters by prefixing them with \. We protect periods, commas, and backslashes themselves.
Parameters:
str - The String to be searched for protected characters.
Returns:
The input String with protected characters marked.