com.googlecode.whatswrong
Class TokenProperty

java.lang.Object
  extended by com.googlecode.whatswrong.TokenProperty
All Implemented Interfaces:
java.lang.Comparable<TokenProperty>

public class TokenProperty
extends java.lang.Object
implements java.lang.Comparable<TokenProperty>

A TokenProperty represents a property of a token, such as the 'Word' or "PoS-Tag' property. A Token then maps such properties to property values, such as "house" or "NN". Each TokenProperty has a name (say 'Word') and an integer 'level' that can be used to define an order on properties. This order is for example used when the properties of a token are stacked under each other in the graphical representation of a token.

Author:
Sebastian Riedel

Constructor Summary
TokenProperty(int level)
          Creates a property with the given level and the name 'Property [level]' where [level] will be replaced with the given level.
TokenProperty(java.lang.String name)
          Creates a property with the given name and level 0.
TokenProperty(java.lang.String name, int level)
          Create new property with given name and level.
 
Method Summary
 int compareTo(TokenProperty o)
          First compares the level of the two properties and if these are equal the property names are compared.
 boolean equals(java.lang.Object o)
          Two TokenProperty objects are equal iff their names match.
 int getLevel()
          Returns the level of the property.
 java.lang.String getName()
          Returns the name of the property.
 int hashCode()
          Calculates a hashcode based on the property name.
 java.lang.String toString()
          Returns the name of the property.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TokenProperty

public TokenProperty(java.lang.String name,
                     int level)
Create new property with given name and level.

Parameters:
name - the name of the property.
level - the level of the property.

TokenProperty

public TokenProperty(java.lang.String name)
Creates a property with the given name and level 0.

Parameters:
name - the name of the property.

TokenProperty

public TokenProperty(int level)
Creates a property with the given level and the name 'Property [level]' where [level] will be replaced with the given level.

Parameters:
level - the level of the property.
Method Detail

toString

public java.lang.String toString()
Returns the name of the property.

Overrides:
toString in class java.lang.Object
Returns:
the name of the property.

getName

public java.lang.String getName()
Returns the name of the property.

Returns:
the name of the property.

getLevel

public int getLevel()
Returns the level of the property.

Returns:
the level of the property.

equals

public boolean equals(java.lang.Object o)
Two TokenProperty objects are equal iff their names match.

Overrides:
equals in class java.lang.Object
Parameters:
o - the other property.
Returns:
true iff the property names match.

hashCode

public int hashCode()
Calculates a hashcode based on the property name.

Overrides:
hashCode in class java.lang.Object
Returns:
a hashcode based on the property name.

compareTo

public int compareTo(TokenProperty o)
First compares the level of the two properties and if these are equal the property names are compared.

Specified by:
compareTo in interface java.lang.Comparable<TokenProperty>
Parameters:
o - the other property.
Returns:
a value larger than 0 if this level is larger than the other level or the levels equal and this name is lexicographically larger than the other. A value smaller than 0 is returned if this level is smaller than the other level or the levels equal and this name is lexicographically smaller than the other. Otherwise 0 is returned.


Copyright © 2009. All Rights Reserved.