LBJ2.classify
Class Feature

java.lang.Object
  extended byLBJ2.classify.Feature
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable, java.io.Serializable
Direct Known Subclasses:
DiscreteFeature, RealFeature

public abstract class Feature
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable, java.io.Serializable

Objects of this class represent the value of a Classifier's decision.

See Also:
Serialized Form

Field Summary
protected  java.lang.String containingPackage
          The Java package containing the classifier that produced this feature.
protected  java.lang.String identifier
          The identifier string distinguishes this Feature from other Features.
 
Constructor Summary
Feature(java.lang.String p, java.lang.String i)
          Initializing constructor.
 
Method Summary
 java.lang.Object clone()
          Returns a shallow clone of this Feature.
 int compareTo(java.lang.Object o)
          Used to sort features via a lexicographic comparison of their packages and identifiers.
abstract  Feature conjunction(Feature f, Classifier c)
          Create a feature representing the conjunction of this feature with the given argument feature.
protected abstract  Feature conjunctWith(DiscreteArrayFeature f, Classifier c)
          Create a feature representing the conjunction of this feature with the given argument feature.
protected abstract  Feature conjunctWith(DiscreteFeature f, Classifier c)
          Create a feature representing the conjunction of this feature with the given argument feature.
protected abstract  Feature conjunctWith(RealArrayFeature f, Classifier c)
          Create a feature representing the conjunction of this feature with the given argument feature.
protected abstract  Feature conjunctWith(RealFeature f, Classifier c)
          Create a feature representing the conjunction of this feature with the given argument feature.
 boolean equals(java.lang.Object o)
          Two Features are equal when their packages and identifiers are equivalent.
 boolean fromArray()
          Determines if this feature comes from an array.
 java.lang.String getIdentifier()
          Retrieves this feature's identifier.
 java.lang.String getPackage()
          Retrieves this feature's package.
abstract  java.lang.String getStringValue()
          Gives a string representation of the value of this feature.
 int hashCode()
          The hash code of a Feature is the hash code of its package plus the hash code of its identifier.
 void intern()
          Makes sure that the identifier is intern()ed.
 boolean nameEquals(Feature f)
          Determines whether the argument feature has equivalent package and identifier.
private  void readObject(java.io.ObjectInputStream in)
          Special handling during deserialization to ensure that Strings are intern()ed.
 void setArrayLength(int l)
          If this feature is an array feature, call this method to set its array length; otherwise, this method has no effect.
 int totalValues()
          Returns the total number of values this feature might possibly be set to.
abstract  boolean valueEquals(java.lang.String v)
          Determines whether or not the parameter is equivalent to the string representation of the value of this feature.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

containingPackage

protected java.lang.String containingPackage
The Java package containing the classifier that produced this feature.


identifier

protected java.lang.String identifier
The identifier string distinguishes this Feature from other Features.

Constructor Detail

Feature

public Feature(java.lang.String p,
               java.lang.String i)
Initializing constructor.

Parameters:
p - The package containing the classifier that produced this feature.
i - The new feature's identifier.
Method Detail

getPackage

public java.lang.String getPackage()
Retrieves this feature's package.


getIdentifier

public java.lang.String getIdentifier()
Retrieves this feature's identifier.


getStringValue

public abstract java.lang.String getStringValue()
Gives a string representation of the value of this feature.

Returns:
A string representation of the value of this feature.

nameEquals

public boolean nameEquals(Feature f)
Determines whether the argument feature has equivalent package and identifier.

Parameters:
f - The feature with which to compare this feature.
Returns:
true iff f has identical containing package and equivalent identifier.

valueEquals

public abstract boolean valueEquals(java.lang.String v)
Determines whether or not the parameter is equivalent to the string representation of the value of this feature.

Parameters:
v - The string to compare against.
Returns:
true iff the parameter is equivalent to the string representation of the value of this feature.

intern

public void intern()
Makes sure that the identifier is intern()ed. Note that the containing package need not be intern()ed since it's always initialized with literals.


fromArray

public boolean fromArray()
Determines if this feature comes from an array.

Returns:
true iff this feature comes from an array.

totalValues

public int totalValues()
Returns the total number of values this feature might possibly be set to.

Returns:
Some integer greater than 1 iff this feature is a discrete feature with a specified value list, and 0 otherwise.

setArrayLength

public void setArrayLength(int l)
If this feature is an array feature, call this method to set its array length; otherwise, this method has no effect.

Parameters:
l - The new length.

conjunction

public abstract Feature conjunction(Feature f,
                                    Classifier c)
Create a feature representing the conjunction of this feature with the given argument feature.

Parameters:
f - The feature to conjunct with.
c - The classifier producing the resulting feature.
Returns:
A feature representing the conjunction of this feature and f.

conjunctWith

protected abstract Feature conjunctWith(DiscreteFeature f,
                                        Classifier c)
Create a feature representing the conjunction of this feature with the given argument feature.

Parameters:
f - The feature to conjunct with.
c - The classifier producing the resulting feature.
Returns:
A feature representing the conjunction of this feature and f.

conjunctWith

protected abstract Feature conjunctWith(DiscreteArrayFeature f,
                                        Classifier c)
Create a feature representing the conjunction of this feature with the given argument feature.

Parameters:
f - The feature to conjunct with.
c - The classifier producing the resulting feature.
Returns:
A feature representing the conjunction of this feature and f.

conjunctWith

protected abstract Feature conjunctWith(RealFeature f,
                                        Classifier c)
Create a feature representing the conjunction of this feature with the given argument feature.

Parameters:
f - The feature to conjunct with.
c - The classifier producing the resulting feature.
Returns:
A feature representing the conjunction of this feature and f.

conjunctWith

protected abstract Feature conjunctWith(RealArrayFeature f,
                                        Classifier c)
Create a feature representing the conjunction of this feature with the given argument feature.

Parameters:
f - The feature to conjunct with.
c - The classifier producing the resulting feature.
Returns:
A feature representing the conjunction of this feature and f.

hashCode

public int hashCode()
The hash code of a Feature is the hash code of its package plus the hash code of its identifier.

Returns:
The hash code of this Feature.

equals

public boolean equals(java.lang.Object o)
Two Features are equal when their packages and identifiers are equivalent.

Returns:
true iff the argument is an equivalent Feature.

compareTo

public int compareTo(java.lang.Object o)
Used to sort features via a lexicographic comparison of their packages and identifiers.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - An object to compare with.
Returns:
The same thing that a String comparison of the concatenations of the features' packages and identifiers would return.

clone

public java.lang.Object clone()
Returns a shallow clone of this Feature.


readObject

private void readObject(java.io.ObjectInputStream in)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Special handling during deserialization to ensure that Strings are intern()ed.

Parameters:
in - The stream to deserialize from.
Throws:
java.io.IOException
java.lang.ClassNotFoundException