de.fu_berlin.ties.classify.feature
Class Feature

java.lang.Object
  extended by de.fu_berlin.ties.classify.feature.Feature
Direct Known Subclasses:
DefaultFeature, GlobalFeature, LocalFeature

public abstract class Feature
extends Object

An abstract base class for immutable feature representation used for classification.

Version:
$Revision: 1.14 $, $Date: 2006/10/21 16:03:57 $, $Author: siefkes $
Author:
Christian Siefkes

Constructor Summary
Feature()
          Creates a new instance, without storing a comment.
Feature(String myComment)
          Creates a new instance.
 
Method Summary
 Long compactRepresentation()
          Returns a compact representation for this object.
 boolean equals(Object obj)
          Indicates whether some other object is "equal to" this one, fulfulling the Object.equals(java.lang.Object) contract.
 String getComment()
          Returns the comment attached to this feature, if any.
 String getFullRepresentation()
          Prints a full representation of this feature that contains both representation (if any) and comment (if any).
 String getFullRepresentation(String separator)
          Prints a full representation of this feature that contains both representation (if any) and comment (if any).
abstract  String getRepresentation()
          Abstract method for returning the representation of this feature, to be used for classification.
 Object[] getUserData()
          Returns an array of objects that can be used by a user to store additional information about this feature; not used by default.
 int hashCode()
          Deprecated. use compactRepresentation() instead
 void setUserData(Object[] newUserData)
          Replaces the array of objects that can be used by a user to stor additional information about this feature.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Feature

public Feature()
Creates a new instance, without storing a comment.


Feature

public Feature(String myComment)
Creates a new instance.

Parameters:
myComment - a comment on this feature, ignored for classification; might be null
Method Detail

compactRepresentation

public Long compactRepresentation()
Returns a compact representation for this object. This implementation delegates to Util.longHash(String).

Returns:
a long hash code value representing this object

equals

public boolean equals(Object obj)
Indicates whether some other object is "equal to" this one, fulfulling the Object.equals(java.lang.Object) contract. To be considered equal, the object must be a Feature. If the representation of this instance is not null, the representations of the two features are compared. Otherwise the full representations are compared. Thus for normal features comments and other fields will be ignored. For comment-only features, comments will be considered, other fields will be ignored.

Overrides:
equals in class Object
Parameters:
obj - the reference object with which to compare
Returns:
true iff the specified object is a Feature equal to this instance

getComment

public String getComment()
Returns the comment attached to this feature, if any.

Returns:
the comment, or null is no comment was stored

getUserData

public Object[] getUserData()
Returns an array of objects that can be used by a user to store additional information about this feature; not used by default.

Returns:
the value of the attribute, defaults to null

getFullRepresentation

public String getFullRepresentation()
Prints a full representation of this feature that contains both representation (if any) and comment (if any). The comment is preceded by a "#" character.

Returns:
the full representation

getFullRepresentation

public String getFullRepresentation(String separator)
Prints a full representation of this feature that contains both representation (if any) and comment (if any). The comment is preceded by the specified separator (surrounded by spaces).

Parameters:
separator - used to introduce the comment
Returns:
the full representation

getRepresentation

public abstract String getRepresentation()
Abstract method for returning the representation of this feature, to be used for classification.

Returns:
the feature representation, or null if this feature contains only a comment

hashCode

public int hashCode()
Deprecated. use compactRepresentation() instead

Returns a hash code value for this object, fulfulling the Object.hashCode() contract.

Overrides:
hashCode in class Object
Returns:
a hash code value for this object

setUserData

public void setUserData(Object[] newUserData)
Replaces the array of objects that can be used by a user to stor additional information about this feature.

Parameters:
newUserData - the new value of the attribute

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object
Returns:
a textual representation


Copyright © 2003-2007 Christian Siefkes. All Rights Reserved.