standup.lexicon
Class WordForm

java.lang.Object
  extended by standup.lexicon.StructElement
      extended by standup.lexicon.Keyword
          extended by standup.lexicon.WordForm
All Implemented Interfaces:
Serializable, Comparable, SQLSelectElement, Unifiable, XMLizable

public class WordForm
extends Keyword
implements Comparable, Serializable

A WordForm is a word with a unique orthographic and phonetic spelling.

Instances of this class are obtained through Dictionary.getWordForm(String), which accesses a serialized hashtable, and thus does not require access to the SQL lexical database.

WordForms are essentially read-only objects, they cannot be altered.

Author:
Ruli Manurung
See Also:
Serialized Form

Field Summary
private  String id
           
private static long serialVersionUID
           
private  WordSequence spelling
           
 
Constructor Summary
WordForm(String _id, WordSequence _sp)
          Constructor that provides all necessary details.
 
Method Summary
 int compareTo(Object arg0)
          A definition of compareTo that is consistent with equals(Object).
 boolean equals(Object obj)
           
 String getID()
          Returns the unique ID of this WordForm.
 WordSequence getSpelling()
          Returns the linearized surface form of this (possibly hierarchical) StructElement as a WordSequence.
 String getSQLSelectString()
          Returns a String that encodes how this WordForm would be used in an SQL query, i.e.
 int hashCode()
           
static WordForm readXML(Element e)
          Returns an instance of a WordForm from an appropriate XML Element.
 String toString()
           
 void writeXML(Writer out, String indent)
          Implementation of XMLizable.writeXML(Writer, String).
 
Methods inherited from class standup.lexicon.Keyword
createKeyword, duplicate, readXMLList
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

id

private final String id

spelling

private final WordSequence spelling
Constructor Detail

WordForm

public WordForm(String _id,
                WordSequence _sp)
Constructor that provides all necessary details. This should only ever be called by ProtoWordForm#buildSerializedCache(String) when building the serialized hashtable of WordForms to be used by Dictionary.

Parameters:
_id - The unique ID
_sp - The orthographic spelling
Method Detail

getID

public String getID()
Returns the unique ID of this WordForm.

Returns:

getSpelling

public WordSequence getSpelling()
Description copied from class: StructElement
Returns the linearized surface form of this (possibly hierarchical) StructElement as a WordSequence.

Specified by:
getSpelling in class StructElement
Returns:

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

compareTo

public int compareTo(Object arg0)
A definition of compareTo that is consistent with equals(Object). It checks the spelling, and only if it is equal is the id used as a 'tiebreaker'.

Specified by:
compareTo in interface Comparable
Parameters:
arg0 -
Returns:

getSQLSelectString

public String getSQLSelectString()
Returns a String that encodes how this WordForm would be used in an SQL query, i.e. its ID enclosed within single quotes, e.g. "'wf123456'".

Specified by:
getSQLSelectString in interface SQLSelectElement
Returns:

writeXML

public void writeXML(Writer out,
                     String indent)
              throws IOException
Implementation of XMLizable.writeXML(Writer, String). Writes out this WordForm's id in a wf tag, e.g. <wf>wf123456</wf>.

Specified by:
writeXML in interface XMLizable
Parameters:
out - The output stream for the XML file, which is assumed to be already opened and writable.
indent - A string to be prepended before every line written by this method. If passed appropriate white space, e.g. XMLUtils.xmlIndent, it can be used to control indentation.
Throws:
IOException

readXML

public static WordForm readXML(Element e)
Returns an instance of a WordForm from an appropriate XML Element.

Parameters:
e - The Element containing the information regarding the WordForm to be instantiated
Returns:
The instantiated WordForm