edu.northwestern.at.wordhoard.model
Class Word

java.lang.Object
  extended by edu.northwestern.at.wordhoard.model.Word
All Implemented Interfaces:
PersistentObject, SearchDefaults, java.lang.Comparable

public class Word
extends java.lang.Object
implements PersistentObject, SearchDefaults, java.lang.Comparable

A word occurrence.

A word records an occurrence of a specific word in a specific work at a specific location. Each word occurrence has the following attributes:

The tag is required. It permanently and uniquely identifies the word occurrence across all corpora. It may be used to refer to the word from outside the object model. It is guaranteed not to change across versions of the object model. For example, the tag for the first word in Hamlet Act 3, Scene 2 is "sha-ham30200101".


Constructor Summary
Word()
          Creates a new word.
 
Method Summary
 int compareTo(java.lang.Object obj)
          Implement Comparable interface.
 boolean equals(java.lang.Object obj)
          Returns true if some other object is equal to this one.
 void export(TableExporterImporter exporterImporter)
          Exports the object to a MySQL table exporter/importer.
 Spelling getBriefDescription()
          Gets a brief description of a word.
 long getColocationOrdinal()
          Gets the colocation ordinal.
 java.util.List getGroupingObjects(java.lang.Class groupBy, int partIndex)
          Gets grouping objects.
 java.lang.Long getId()
          Gets the unique id.
 Line getLine()
          Gets the line.
 TextRange getLocation()
          Gets the word location.
 MetricalShape getMetricalShape()
          Gets the metrical shape.
 Word getNext()
          Gets the next word.
 java.lang.String getPath()
          Gets the path.
 Word getPrev()
          Gets the previous word.
 Prosodic getProsodic()
          Gets the prosodic attribute.
 java.lang.String getPuncAfter()
          Gets the punctuation following the word.
 java.lang.String getPuncBefore()
          Gets the punctuation preceding the word.
 SearchCriterion getSearchDefault(java.lang.Class cls)
          Gets a search criterion default value.
 Speech getSpeech()
          Gets the speech.
 Spelling getSpelling()
          Gets the spelling.
 Spelling getSpellingInsensitive()
          Gets the insensitive spelling.
 java.lang.String getTag()
          Gets the tag.
 java.util.List getWordParts()
          Gets the word parts.
 Work getWork()
          Gets the work.
 int getWorkOrdinal()
          Gets the work ordinal.
 WorkPart getWorkPart()
          Gets the work part.
 java.lang.String getWorkTag()
          Gets the work tag.
 int hashCode()
          Returns a hash code for the object.
 void initDerivedValues()
          Initializes derived values.
 void setId(java.lang.Long id)
          Sets the unique id.
 void setLine(Line line)
          Sets the line.
 void setLocation(TextRange location)
          Sets the word location.
 void setMetricalShape(MetricalShape metricalShape)
          Sets the metrical shape.
 void setMetricalShape(java.lang.String metricalShape)
          Sets the metrical shape.
 void setNext(Word next)
          Sets the next word.
 void setPrev(Word prev)
          Sets the previous word.
 void setProsodic(byte prosodic)
          Sets the prosodic attribute.
 void setProsodic(Prosodic prosodic)
          Sets the prosodic attribute.
 void setPuncAfter(java.lang.String puncAfter)
          Sets the punctuation following the word.
 void setPuncBefore(java.lang.String puncBefore)
          Sets the punctuation preceding the word.
 void setSpeech(Speech speech)
          Sets the speech.
 void setSpelling(Spelling spelling)
          Sets the spelling.
 void setTag(java.lang.String tag)
          Sets the tag.
 void setWorkOrdinal(int workOrdinal)
          Sets the work ordinal.
 void setWorkPart(WorkPart workPart)
          Sets the work part.
 void setWorkTag(java.lang.String workTag)
          Sets the work tag.
 java.lang.String toString()
          Gets a string representation of the word.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Word

public Word()
Creates a new word.

Method Detail

getId

public java.lang.Long getId()
Gets the unique id.

Specified by:
getId in interface PersistentObject
Returns:
The unique id.

setId

public void setId(java.lang.Long id)
Sets the unique id.

Parameters:
id - The unique id.

getSpelling

public Spelling getSpelling()
Gets the spelling.

Returns:
The spelling.

setSpelling

public void setSpelling(Spelling spelling)
Sets the spelling.

This method also sets the spelling mapped to lower case.

Parameters:
spelling - The spelling.

getSpellingInsensitive

public Spelling getSpellingInsensitive()
Gets the insensitive spelling.

Returns:
The spelling with all diacriticals removed and mapped to lower case.

getWorkPart

public WorkPart getWorkPart()
Gets the work part.

Returns:
The work part.

setWorkPart

public void setWorkPart(WorkPart workPart)
Sets the work part.

This method also sets the work.

Parameters:
workPart - The work part.

getWork

public Work getWork()
Gets the work.

Returns:
The work.

getLine

public Line getLine()
Gets the line.

Returns:
The line, or null if none.

setLine

public void setLine(Line line)
Sets the line.

Parameters:
line - The line.

getPath

public java.lang.String getPath()
Gets the path.

Returns:
The path.

getTag

public java.lang.String getTag()
Gets the tag.

Returns:
The tag.

setTag

public void setTag(java.lang.String tag)
Sets the tag.

Parameters:
tag - The tag.

getLocation

public TextRange getLocation()
Gets the word location.

Returns:
The word location.

setLocation

public void setLocation(TextRange location)
Sets the word location.

Parameters:
location - The word location in the part text.

getPuncBefore

public java.lang.String getPuncBefore()
Gets the punctuation preceding the word.

Returns:
The punctuation preceding the word.

setPuncBefore

public void setPuncBefore(java.lang.String puncBefore)
Sets the punctuation preceding the word.

Parameters:
puncBefore - The punctuation preceding the word.

getPuncAfter

public java.lang.String getPuncAfter()
Gets the punctuation following the word.

Returns:
The punctuation following the word.

setPuncAfter

public void setPuncAfter(java.lang.String puncAfter)
Sets the punctuation following the word.

Parameters:
puncAfter - The punctuation following the word.

getPrev

public Word getPrev()
Gets the previous word.

Returns:
The previous word.

setPrev

public void setPrev(Word prev)
Sets the previous word.

Parameters:
prev - The previous word.

getNext

public Word getNext()
Gets the next word.

Returns:
The next word.

setNext

public void setNext(Word next)
Sets the next word.

Parameters:
next - The next word.

getWordParts

public java.util.List getWordParts()
Gets the word parts.

Returns:
The word parts as an unmodifiable list.

getWorkTag

public java.lang.String getWorkTag()
Gets the work tag.

Returns:
The work tag.

setWorkTag

public void setWorkTag(java.lang.String workTag)
Sets the work tag.

Parameters:
workTag - The work tag.

getWorkOrdinal

public int getWorkOrdinal()
Gets the work ordinal.

Returns:
The ordinal of the word within the work.

setWorkOrdinal

public void setWorkOrdinal(int workOrdinal)
Sets the work ordinal.

Parameters:
workOrdinal - The ordinal of the word within the work.

getColocationOrdinal

public long getColocationOrdinal()
Gets the colocation ordinal.

Returns:
The colocation ordinal.

getSpeech

public Speech getSpeech()
Gets the speech.

Returns:
The speech, or null if none.

setSpeech

public void setSpeech(Speech speech)
Sets the speech.

Parameters:
speech - The speech, or null if none.

getProsodic

public Prosodic getProsodic()
Gets the prosodic attribute.

Returns:
The prosodic attribute.

setProsodic

public void setProsodic(Prosodic prosodic)
Sets the prosodic attribute.

Parameters:
prosodic - The prosodic attibute.

setProsodic

public void setProsodic(byte prosodic)
Sets the prosodic attribute.

Parameters:
prosodic - The prosodic attibute.

getMetricalShape

public MetricalShape getMetricalShape()
Gets the metrical shape.

Returns:
The metrical shape.

setMetricalShape

public void setMetricalShape(MetricalShape metricalShape)
Sets the metrical shape.

Parameters:
metricalShape - The metrical shape.

setMetricalShape

public void setMetricalShape(java.lang.String metricalShape)
Sets the metrical shape.

Parameters:
metricalShape - The metrical shape.

initDerivedValues

public void initDerivedValues()
Initializes derived values.

Sets the colocation ordinal to partId << 32 | workOrdinal, where partId = the persistence id of the work part. The work part and work ordinal must be set, and the work part must have a persistence id.

Sets the word path. The line and work part must be set.


getSearchDefault

public SearchCriterion getSearchDefault(java.lang.Class cls)
Gets a search criterion default value.

Specified by:
getSearchDefault in interface SearchDefaults
Parameters:
cls - Model class of search criterion.
Returns:
Default value for search criterion.

getGroupingObjects

public java.util.List getGroupingObjects(java.lang.Class groupBy,
                                         int partIndex)
Gets grouping objects.

Returns the grouping object(s) for the word given a grouping class and a word part index.

Parameters:
groupBy - Grouping class.
partIndex - Part index, or -1 if none.
Returns:
List of grouping objects.

getBriefDescription

public Spelling getBriefDescription()
Gets a brief description of a word.

Returns a brief one line description of the word, suitable for display in a tool tip or as a footnote.

For compound words (words with more than one part), the brief description is simply "compound word".

Otherwise, if a Benson gloss is available, the description includes his lemma, part of speech, and definition.

Otherwise, the description includes the lemma word and part of speech.

Returns:
The brief description of the word, or null if none available.

toString

public java.lang.String toString()
Gets a string representation of the word.

Overrides:
toString in class java.lang.Object
Returns:
The tag.

export

public void export(TableExporterImporter exporterImporter)
Exports the object to a MySQL table exporter/importer.

Parameters:
exporterImporter - MySQL table exporter/importer.

equals

public boolean equals(java.lang.Object obj)
Returns true if some other object is equal to this one.

The two words are equal if their work parts and tags are equal.

Overrides:
equals in class java.lang.Object
Parameters:
obj - The other object.
Returns:
True if this object equals the other object.

hashCode

public int hashCode()
Returns a hash code for the object.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code.

compareTo

public int compareTo(java.lang.Object obj)
Implement Comparable interface.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
obj - Other word object to which to compare this object.

The word tag is used for comparison.