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

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

public class PhraseSet
extends WordSet
implements java.io.Serializable, CanCountWords, CanCountPhrases, PersistentObject, SearchCriterion, UserDataObject

A phrase set.

A phrase set contains a list of phrases. Typically these come from various works and do not necessarily appear sequentially.

Each phrase set has the following attributes in addition to those defined for word sets.

See Also:
Serialized Form

Field Summary
protected  java.util.Collection phrases
          Collection of phrases belonging to this phrase set.
protected  double sumPhraseLengths
          Sum of the phrase lengths.
 
Fields inherited from class edu.northwestern.at.wordhoard.model.userdata.WordSet
creationTime, description, id, isActive, isPublic, modificationTime, owner, query, serialVersionUID, title, webPageURL, wordTags, workPartTags, workTags
 
Constructor Summary
PhraseSet()
          Create an empty phrase set.
PhraseSet(org.w3c.dom.Node phraseSetNode, java.lang.String owner)
          Create a phrase set from a DOM document node.
PhraseSet(java.lang.String title, java.lang.String description, java.lang.String webPageURL, java.lang.String owner, boolean isPublic)
          Create an empty phrase set with a specified name.
PhraseSet(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 phrase set with a specified name and query string.
 
Method Summary
 void addPhrase(Phrase phrase)
          Adds a phrase.
 void addPhrases(java.util.Collection phraseCollection)
          Adds phrases from a collection of phrases.
 void addPhrases(Phrase[] phraseArray)
          Adds phrases from an array of phrases.
 boolean addToDOMDocument(org.w3c.dom.Document document)
          Add phrase set to DOM document.
 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.
 Spelling getGroupingSpelling(int numHits)
          Gets the spelling of the grouping object.
 java.lang.Class getJoinClass()
          Gets the join class.
 double getMeanPhraseLength()
          Get mean phrase length.
 int getPhraseCount()
          Get the number of phrases.
 java.util.Collection getPhrases()
          Get the phrases.
 java.lang.String getReportPhrase()
          Gets the report phrase.
 SearchCriterion getSearchDefault(java.lang.Class cls)
          Gets a search criterion default value.
 double getSumPhraseLengths()
          Get sum of the phrase lengths.
 java.lang.String getWhereClause()
          Gets the Hibernate where clause.
 int hashCode()
          Returns a hash code for the object.
 void removePhrases()
          Removes all the phrases.
 void setArg(org.hibernate.Query q, org.hibernate.Session session)
          Sets the Hibernate query argument.
 boolean setFromDOMDocumentNode(org.w3c.dom.Node phraseSetNode)
          Set values from DOM document node.
 java.lang.String toString()
          Gets a string representation of the phrase set.
 java.lang.String toStringDetailed()
          Gets a detailed string representation of the phrase set.
 
Methods inherited from class edu.northwestern.at.wordhoard.model.userdata.WordSet
addWord, addWords, addWords, addWordTags, addWordTags, addWorkPartTags, addWorkTags, getCreationTime, getDescription, getId, getIsActive, getIsPublic, getModificationTime, getOwner, getQuery, getTitle, getWebPageURL, getWordTags, getWorkPartTags, getWorkTags, readExternal, removeWords, setCreationTime, setDescription, setIsActive, setIsPublic, setModificationTime, setOwner, setQuery, setTitle, setWebPageURL, writeExternal
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.northwestern.at.wordhoard.model.PersistentObject
getId
 
Methods inherited from interface edu.northwestern.at.wordhoard.model.userdata.UserDataObject
getCreationTime, getDescription, getId, getIsActive, getIsPublic, getModificationTime, getOwner, getQuery, getTitle, getWebPageURL, setCreationTime, setDescription, setModificationTime, setTitle, setWebPageURL
 

Field Detail

phrases

protected java.util.Collection phrases
Collection of phrases belonging to this phrase set.

Element type is Phrase.


sumPhraseLengths

protected double sumPhraseLengths
Sum of the phrase lengths. Used to compute average phrase length.

Constructor Detail

PhraseSet

public PhraseSet()
Create an empty phrase set.


PhraseSet

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

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

PhraseSet

public PhraseSet(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 phrase set with a specified name and query string.

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

PhraseSet

public PhraseSet(org.w3c.dom.Node phraseSetNode,
                 java.lang.String owner)
Create a phrase set from a DOM document node.

Parameters:
phraseSetNode - The root node for the phrase set.
owner - The phrase set's owner.
Method Detail

getPhrases

public java.util.Collection getPhrases()
Get the phrases.

Returns:
The phrases as an unmodifiable collection.

getSumPhraseLengths

public double getSumPhraseLengths()
Get sum of the phrase lengths.

Returns:
The mean phrase length.

getMeanPhraseLength

public double getMeanPhraseLength()
Get mean phrase length.

Returns:
The mean phrase length.

The average phrase length is the sum of the phrase lengths divided by the number of phrases.


getPhraseCount

public int getPhraseCount()
Get the number of phrases.

Returns:
The number of phrases.

addPhrase

public void addPhrase(Phrase phrase)
Adds a phrase.

Parameters:
phrase - The phrase to add.

The words and works are updated as needed.


addPhrases

public void addPhrases(Phrase[] phraseArray)
Adds phrases from an array of phrases.

Parameters:
phraseArray - The phrases as an array.

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


addPhrases

public void addPhrases(java.util.Collection phraseCollection)
Adds phrases from a collection of phrases.

Parameters:
phraseCollection - The phrases as a collection.

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


removePhrases

public void removePhrases()
Removes all the phrases.

All words, work parts, and works are also removed.


addToDOMDocument

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

Specified by:
addToDOMDocument in interface UserDataObject
Overrides:
addToDOMDocument in class WordSet
Parameters:
document - DOM document to which to add phrase 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 phraseSetNode)
Set values from DOM document node.

Specified by:
setFromDOMDocumentNode in interface UserDataObject
Overrides:
setFromDOMDocumentNode in class WordSet
Parameters:
phraseSetNode - DOM document node with phrase set settings.
Returns:
true if settings retrieved.

toString

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

Overrides:
toString in class WordSet
Returns:
The title.

toStringDetailed

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

Overrides:
toStringDetailed in class WordSet
Returns:
The title.

getSearchDefault

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

Overrides:
getSearchDefault in class WordSet
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
Overrides:
getJoinClass in class WordSet
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
Overrides:
getWhereClause in class WordSet
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
Overrides:
setArg in class WordSet
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
Overrides:
appendDescription in class WordSet
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.

Overrides:
getReportPhrase in class WordSet
Returns:
The report phrase "in".

getGroupingSpelling

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

Overrides:
getGroupingSpelling in class WordSet
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 WordSet
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 WordSet
Returns:
The hash code.