edu.northwestern.at.wordhoard.model.userdata
Class WordSet

java.lang.Object
  extended by edu.northwestern.at.wordhoard.model.userdata.WordSet
All Implemented Interfaces:
CanCountWords, PersistentObject, SearchCriterion, UserDataObject, java.io.Externalizable, java.io.Serializable
Direct Known Subclasses:
PhraseSet

public class WordSet
extends java.lang.Object
implements java.io.Externalizable, CanCountWords, PersistentObject, SearchCriterion, UserDataObject

A word set.

A word set contains a list of word occurrences. Typically these come from various works and do not necessarily appear sequentially. For example, a word set might contain all the words used by female speakers in Shakespeare comedies.

Each word set has the following attributes:

See Also:
Serialized Form

Field Summary
protected  java.util.Date creationTime
          Original creation date/time.
protected  java.lang.String description
          Description of word set.
protected  java.lang.Long id
          Unique persistence id (primary key).
protected  boolean isActive
          True if work set is active (available for use).
protected  boolean isPublic
          True if public word set (can be seen by other users), false if private word set.
protected  java.util.Date modificationTime
          Last modification date/time.
protected  java.lang.String owner
          Owner of this word set.
protected  java.lang.String query
          The query which generates this word set's word list.
protected static long serialVersionUID
          Serial version UID.
protected  java.lang.String title
          The title of the word set.
protected  java.lang.String webPageURL
          Web page URL.
protected  java.util.Collection wordTags
          Collection of words belonging to this word set.
protected  java.util.Collection workPartTags
          Collection of work parts for words.
protected  java.util.Collection workTags
          Collection of works for words.
 
Constructor Summary
WordSet()
          Create an empty word set.
WordSet(org.w3c.dom.Node wordSetNode, java.lang.String owner)
          Create a word set from a DOM document node.
WordSet(java.lang.String title, java.lang.String description, java.lang.String webPageURL, java.lang.String owner, boolean isPublic)
          Create an empty word set with a specified name.
WordSet(java.lang.String title, java.lang.String description, java.lang.String webPageURL, java.lang.String owner, boolean isPublic, java.lang.String query)
          Create an empty word set with a specified name and query string.
 
Method Summary
 boolean addToDOMDocument(org.w3c.dom.Document document)
          Add word set to DOM document.
 void addWord(Word word)
          Adds a word Id from a Word object.
 void addWords(java.util.Collection wordCollection)
          Adds words from a collection of Word.
 void addWords(Word[] wordArray)
          Adds words from an array of Word.
 void addWordTags(java.util.Collection wordTags)
          Adds word tags.
 void addWordTags(java.lang.String[] wordTagsArray)
          Adds word tags.
 void addWorkPartTags(java.lang.String[] workPartTagsArray)
          Adds work part tags.
 void addWorkTags(java.lang.String[] workTagsArray)
          Adds work tags.
 void appendDescription(TextLine line, FontInfo romanFontInfo, FontInfo[] fontInfo)
          Appends a description to a text line.
 boolean equals(java.lang.Object obj)
          Returns true if some other object is equal to this one.
 java.util.Date getCreationTime()
          Gets the creation date.
 java.lang.String getDescription()
          Gets the description.
 Spelling getGroupingSpelling(int numHits)
          Gets the spelling of the grouping object.
 java.lang.Long getId()
          Gets the unique id.
 boolean getIsActive()
          Get the active flag.
 boolean getIsPublic()
          Get the public flag.
 java.lang.Class getJoinClass()
          Gets the join class.
 java.util.Date getModificationTime()
          Gets the modification date.
 java.lang.String getOwner()
          Get the owner.
 java.lang.String getQuery()
          Get the query.
 java.lang.String getReportPhrase()
          Gets the report phrase.
 SearchCriterion getSearchDefault(java.lang.Class cls)
          Gets a search criterion default value.
 java.lang.String getTitle()
          Gets the title.
 java.lang.String getWebPageURL()
          Gets the web page URL.
 java.lang.String getWhereClause()
          Gets the Hibernate where clause.
 java.util.Collection getWordTags()
          Get the word tags.
 java.util.Collection getWorkPartTags()
          Get the work part tags.
 java.util.Collection getWorkTags()
          Gets the work tags.
 int hashCode()
          Returns a hash code for the object.
 void readExternal(java.io.ObjectInput in)
          Reads the word set from an object input stream (deserializes the object).
 void removeWords()
          Removes all the words.
 void setArg(org.hibernate.Query q, org.hibernate.Session session)
          Sets the Hibernate query argument.
 void setCreationTime(java.util.Date creationTime)
          Sets the creation time.
 void setDescription(java.lang.String description)
          Sets the description.
 boolean setFromDOMDocumentNode(org.w3c.dom.Node wordSetNode)
          Set values from DOM document node.
 void setIsActive(boolean isActive)
          Set the active flag.
 void setIsPublic(boolean isPublic)
          Set the public flag.
 void setModificationTime(java.util.Date modificationTime)
          Sets the modification time.
 void setOwner(java.lang.String owner)
          Set the owner.
 void setQuery(java.lang.String query)
          Set the query.
 void setTitle(java.lang.String title)
          Sets the title.
 void setWebPageURL(java.lang.String webPageURL)
          Sets the web page URL.
 java.lang.String toString()
          Gets a string representation of the word set.
 java.lang.String toStringDetailed()
          Gets a detailed string representation of the word set.
 void writeExternal(java.io.ObjectOutput out)
          Writes the word set to an object output stream (serializes the object).
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

protected static final long serialVersionUID
Serial version UID.

See Also:
Constant Field Values

id

protected java.lang.Long id
Unique persistence id (primary key).


title

protected java.lang.String title
The title of the word set.


description

protected java.lang.String description
Description of word set.


webPageURL

protected java.lang.String webPageURL
Web page URL.


creationTime

protected java.util.Date creationTime
Original creation date/time.


modificationTime

protected java.util.Date modificationTime
Last modification date/time.


wordTags

protected java.util.Collection wordTags
Collection of words belonging to this word set.

Element type is String. The strings are the unique word tags.


owner

protected java.lang.String owner
Owner of this word set.


isPublic

protected boolean isPublic
True if public word set (can be seen by other users), false if private word set.


isActive

protected boolean isActive
True if work set is active (available for use).


query

protected java.lang.String query
The query which generates this word set's word list.


workTags

protected java.util.Collection workTags
Collection of works for words. Element type is String. The elements are the work part reference tags.


workPartTags

protected java.util.Collection workPartTags
Collection of work parts for words. Element type is String. The elements are the work part reference tags.

Constructor Detail

WordSet

public WordSet()
Create an empty word set.


WordSet

public WordSet(java.lang.String title,
               java.lang.String description,
               java.lang.String webPageURL,
               java.lang.String owner,
               boolean isPublic)
Create an empty word set with a specified name.

Parameters:
title - The word set's title.
description - The word set's description.
webPageURL - The word set's web page URL.
owner - The word set's owner.
isPublic - True if the word set is public.

WordSet

public WordSet(java.lang.String title,
               java.lang.String description,
               java.lang.String webPageURL,
               java.lang.String owner,
               boolean isPublic,
               java.lang.String query)
Create an empty word set with a specified name and query string.

Parameters:
title - The word set's title.
description - The word set's description.
webPageURL - The word set's web page URL.
owner - The word set's owner.
isPublic - True if the word set is public.
query - Query properties for generating this word set.

WordSet

public WordSet(org.w3c.dom.Node wordSetNode,
               java.lang.String owner)
Create a word set from a DOM document node.

Parameters:
wordSetNode - The root node for the word set.
owner - The word set's owner.
Method Detail

getId

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

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

getTitle

public java.lang.String getTitle()
Gets the title.

Specified by:
getTitle in interface UserDataObject
Returns:
The title.

getDescription

public java.lang.String getDescription()
Gets the description.

Specified by:
getDescription in interface UserDataObject
Returns:
The description.

getWebPageURL

public java.lang.String getWebPageURL()
Gets the web page URL.

Specified by:
getWebPageURL in interface UserDataObject
Returns:
The web page URL.

getCreationTime

public java.util.Date getCreationTime()
Gets the creation date.

Specified by:
getCreationTime in interface UserDataObject
Returns:
The creation date.

getModificationTime

public java.util.Date getModificationTime()
Gets the modification date.

Specified by:
getModificationTime in interface UserDataObject
Returns:
The modification date.

getOwner

public java.lang.String getOwner()
Get the owner.

Specified by:
getOwner in interface UserDataObject
Returns:
The owner.

getIsPublic

public boolean getIsPublic()
Get the public flag.

Specified by:
getIsPublic in interface UserDataObject
Returns:
True if the word set is public, false if private.

getIsActive

public boolean getIsActive()
Get the active flag.

Specified by:
getIsActive in interface UserDataObject
Returns:
True if the word set is active.

getQuery

public java.lang.String getQuery()
Get the query.

Specified by:
getQuery in interface UserDataObject
Returns:
The query for generating this word set.

getWordTags

public java.util.Collection getWordTags()
Get the word tags.

Returns:
The word tags as an unmodifiable collection.

getWorkTags

public java.util.Collection getWorkTags()
Gets the work tags.

Returns:
The work tags as an unmodifiable collection.

getWorkPartTags

public java.util.Collection getWorkPartTags()
Get the work part tags.

Returns:
The work part tags as an unmodifiable collection.

setTitle

public void setTitle(java.lang.String title)
Sets the title.

Specified by:
setTitle in interface UserDataObject
Parameters:
title - The title.

setDescription

public void setDescription(java.lang.String description)
Sets the description.

Specified by:
setDescription in interface UserDataObject
Parameters:
description - The description.

setWebPageURL

public void setWebPageURL(java.lang.String webPageURL)
Sets the web page URL.

Specified by:
setWebPageURL in interface UserDataObject
Parameters:
webPageURL - The web page URL.

setCreationTime

public void setCreationTime(java.util.Date creationTime)
Sets the creation time.

Specified by:
setCreationTime in interface UserDataObject
Parameters:
creationTime - The creation time.

setModificationTime

public void setModificationTime(java.util.Date modificationTime)
Sets the modification time.

Specified by:
setModificationTime in interface UserDataObject
Parameters:
modificationTime - The modification time.

setOwner

public void setOwner(java.lang.String owner)
Set the owner.

Parameters:
owner - The owner.

setIsPublic

public void setIsPublic(boolean isPublic)
Set the public flag.

Parameters:
isPublic - True if the word set is public, false if private.

setIsActive

public void setIsActive(boolean isActive)
Set the active flag.

Parameters:
isActive - True if the word set is active.

setQuery

public void setQuery(java.lang.String query)
Set the query.

Parameters:
query - The query for generating this word set.

addWord

public void addWord(Word word)
Adds a word Id from a Word object.

Parameters:
word - The new word.

The work Ids are updated as needed.


addWords

public void addWords(Word[] wordArray)
Adds words from an array of Word.

Parameters:
wordArray - The new words an array.

The work and work part collections are also updated as needed.


addWords

public void addWords(java.util.Collection wordCollection)
Adds words from a collection of Word.

Parameters:
wordCollection - The new words as a collection.

The work and work part collection are also updated as needed.


addWordTags

public void addWordTags(java.lang.String[] wordTagsArray)
Adds word tags.

Parameters:
wordTagsArray - String array of word tags.

addWordTags

public void addWordTags(java.util.Collection wordTags)
Adds word tags.

Parameters:
wordTags - Collection of word tags.

addWorkTags

public void addWorkTags(java.lang.String[] workTagsArray)
Adds work tags.

Parameters:
workTagsArray - String array of work tags.

addWorkPartTags

public void addWorkPartTags(java.lang.String[] workPartTagsArray)
Adds work part tags.

Parameters:
workPartTagsArray - String array of work part tags.

removeWords

public void removeWords()
Removes all the words.


addToDOMDocument

public boolean addToDOMDocument(org.w3c.dom.Document document)
Add word set to DOM document.

Specified by:
addToDOMDocument in interface UserDataObject
Parameters:
document - DOM document to which to add word set. Must not be null. In most cases, this document should have a "wordhoard" node as the root element.
Returns:
true if DOM addition successful, false otherwise.

setFromDOMDocumentNode

public boolean setFromDOMDocumentNode(org.w3c.dom.Node wordSetNode)
Set values from DOM document node.

Specified by:
setFromDOMDocumentNode in interface UserDataObject
Parameters:
wordSetNode - DOM document node with word set settings.
Returns:
true if settings retrieved.

toString

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

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

toStringDetailed

public java.lang.String toStringDetailed()
Gets a detailed string representation of the word set.

Returns:
The title.

getSearchDefault

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

Parameters:
cls - Model class of search criterion.
Returns:
Default value for search criterion.

getJoinClass

public java.lang.Class getJoinClass()
Gets the join class.

Specified by:
getJoinClass in interface SearchCriterion
Returns:
The join class, or null if none.

getWhereClause

public java.lang.String getWhereClause()
Gets the Hibernate where clause.

Specified by:
getWhereClause in interface SearchCriterion
Returns:
The Hibernate where clause.

setArg

public void setArg(org.hibernate.Query q,
                   org.hibernate.Session session)
Sets the Hibernate query argument.

Specified by:
setArg in interface SearchCriterion
Parameters:
q - Hibernate query.
session - Hibernate session.

appendDescription

public void appendDescription(TextLine line,
                              FontInfo romanFontInfo,
                              FontInfo[] fontInfo)
Appends a description to a text line.

Specified by:
appendDescription in interface SearchCriterion
Parameters:
line - Text line.
romanFontInfo - Roman font info.
fontInfo - Array of font info indexed by character set.

getReportPhrase

public java.lang.String getReportPhrase()
Gets the report phrase.

Returns:
The report phrase "in".

getGroupingSpelling

public Spelling getGroupingSpelling(int numHits)
Gets the spelling of the grouping object.

Parameters:
numHits - Number of hits.
Returns:
The spelling of the grouping object.

equals

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

The two objects are equal if their ids 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.

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Writes the word set to an object output stream (serializes the object).

Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
out - Object output stream.
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Reads the word set from an object input stream (deserializes the object).

Specified by:
readExternal in interface java.io.Externalizable
Parameters:
in - Object input stream.
Throws:
java.io.IOException
java.lang.ClassNotFoundException