de.fu_berlin.ties.classify.feature
Class Feature

java.lang.Object
  extended byde.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.1 $, $Date: 2004/03/31 12:08:32 $, $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
 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.
 int hashCode()
          Returns a hash code value for this object, fulfulling the Object.hashCode() contract.
 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

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.

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

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()
Returns a hash code value for this object, fulfulling the Object.hashCode() contract.

Returns:
a hash code value for this object

toString

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

Returns:
a textual representation


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