elge.lexikon
Class Word

java.lang.Object
  |
  +--elge.lexikon.Word
All Implemented Interfaces:
Comparable, Comparator

public class Word
extends Object
implements Comparator, Comparable

The Word class represents one word in the elxikon. It holds also the word use and succes use.

To change some behavior of the lexikon, you can yust change the word.

Author:
Pavol Žibrita

Field Summary
static Word emptyWord
          An ampty word instance used as comparator object.
protected  int sucessUse
          the success use of the word
protected  int use
          the use of the word.
protected  String word
          The word.
 
Constructor Summary
Word()
          Creates empty word.
Word(String word)
          Creates a new instance of word
Word(String word, int use, int suc)
          Creates a new instance of word
 
Method Summary
 int compare(Object o1, Object o2)
          compares two words agains they usage.
 int compareTo(Object o)
          See compare(java.lang.Object, java.lang.Object) Compares this object with the specified object for order.
 void decSucessUse()
          decreases the successfull usage of the word
 void decUse()
          decreases the useage of the word
 boolean equals(Object o)
          See compare(java.lang.Object, java.lang.Object)
 String getAsText()
          Returns a format of the whole word with name, use and success:
[name;use;success]
static Comparator getComparator()
          Return a comparator of use and success.
 double getRatio()
          Returns the ratio -> successUse/Use
 int getSucessUse()
          the succesfull use of the word
 int getUse()
          the use of the word
 String getWord()
          See toString()
static Comparator getWordComparator()
          Returns an comparator of the word itself.
 void incSucessUse()
          increases the successfull usage of the word
 void incUse()
          increases the useage of the word
 void setAsText(String wordRep)
          parse [word;use;sucuse] -->
sets the word from the string
 void setWord(String w)
           
 String toString()
          Returns the word.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

emptyWord

public static final Word emptyWord
An ampty word instance used as comparator object.


use

protected int use
the use of the word.


sucessUse

protected int sucessUse
the success use of the word


word

protected String word
The word.

Constructor Detail

Word

public Word(String word)
Creates a new instance of word

Parameters:
word - Name of the word

Word

public Word(String word,
            int use,
            int suc)
Creates a new instance of word

Parameters:
word - name of the word
use - initial use
suc - initial success

Word

public Word()
Creates empty word.

Method Detail

getComparator

public static Comparator getComparator()
Return a comparator of use and success.

Returns:
Comparator to compare the Words..

getWordComparator

public static Comparator getWordComparator()
Returns an comparator of the word itself.

Returns:
comparator to compare the Word instance against their names.

getUse

public int getUse()
the use of the word

Returns:
int usage

incUse

public void incUse()
increases the useage of the word


decUse

public void decUse()
decreases the useage of the word


incSucessUse

public void incSucessUse()
increases the successfull usage of the word


decSucessUse

public void decSucessUse()
decreases the successfull usage of the word


getSucessUse

public int getSucessUse()
the succesfull use of the word

Returns:
int success use

getRatio

public double getRatio()
Returns the ratio -> successUse/Use

Returns:
the ratio of usage.

toString

public String toString()
Returns the word.

Overrides:
toString in class Object
Returns:
The word name.

getWord

public String getWord()
See toString()

Returns:
the word name

setWord

public void setWord(String w)

compare

public int compare(Object o1,
                   Object o2)
compares two words agains they usage.

Specified by:
compare in interface Comparator
Parameters:
o1 - first word
o2 - second word
Returns:
-1, 0, 1 if o1 is less, equal or bigger then o2.

equals

public boolean equals(Object o)
See compare(java.lang.Object, java.lang.Object)

Specified by:
equals in interface Comparator
Overrides:
equals in class Object
Parameters:
o - compare with
Returns:
true if they are equal.

getAsText

public String getAsText()
Returns a format of the whole word with name, use and success:
[name;use;success]

Returns:
The parsable format of the word

setAsText

public void setAsText(String wordRep)
parse [word;use;sucuse] -->
sets the word from the string

Parameters:
wordRep - The parsable format of the word

compareTo

public int compareTo(Object o)
See compare(java.lang.Object, java.lang.Object) Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

In the foregoing description, the notation sgn(expression) designates the mathematical signum function, which is defined to return one of -1, 0, or 1 according to whether the value of expression is negative, zero or positive. The implementor must ensure sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception iff y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y)>0 && y.compareTo(z)>0) implies x.compareTo(z)>0.

Finally, the implementer must ensure that x.compareTo(y)==0 implies that sgn(x.compareTo(z)) == sgn(y.compareTo(z)), for all z.

It is strongly recommended, but not strictly required that (x.compareTo(y)==0) == (x.equals(y)). Generally speaking, any class that implements the Comparable interface and violates this condition should clearly indicate this fact. The recommended language is "Note: this class has a natural ordering that is inconsistent with equals."

Specified by:
compareTo in interface Comparable
Parameters:
o - the Object to be compared.
Returns:
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.