edu.northwestern.at.wordhoard.model.search
Class SearchCriteria

java.lang.Object
  extended by edu.northwestern.at.wordhoard.model.search.SearchCriteria
Direct Known Subclasses:
SearchCriteriaLemmaSearch, SearchCriteriaLemmaWorkCount

public class SearchCriteria
extends java.lang.Object

A set of word search criteria.


Nested Class Summary
protected static class SearchCriteria.MyStringBuffer
          A string buffer that knows how to append Hibernate where clauses separated by the word "and".
 
Field Summary
protected  java.util.ArrayList criteriaList
          List of search criterion.
 
Constructor Summary
SearchCriteria()
          Creates a new empty set of word search criteria.
SearchCriteria(Corpus corpus, Lemma lemma, Pos pos, Spelling spelling, int strength)
          Creates a new set of word search criteria.
 
Method Summary
 void add(SearchCriterion criterion)
          Adds a criterion.
 boolean contains(java.lang.Class cls)
          Returns true if the critera contains a criterion class.
 Corpus getCorpus()
          Gets the corpus.
 TextLine getDescription(FontInfo[] fontInfo)
          Gets a description of the search criteria.
 java.util.List search(org.hibernate.Session session)
          Executes the query.
 boolean suspicious()
          Returns true if the criteria are "suspicious".
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

criteriaList

protected java.util.ArrayList criteriaList
List of search criterion.

Constructor Detail

SearchCriteria

public SearchCriteria()
Creates a new empty set of word search criteria.


SearchCriteria

public SearchCriteria(Corpus corpus,
                      Lemma lemma,
                      Pos pos,
                      Spelling spelling,
                      int strength)
Creates a new set of word search criteria.

The collation strengths for spelling searches are:

Parameters:
corpus - The corpus to be searched, or null.
lemma - The lemma, or null.
pos - The part of speech, or null.
spelling - The spelling, or null.
strength - Collation strength for spelling searches.
Method Detail

add

public void add(SearchCriterion criterion)
Adds a criterion.

Parameters:
criterion - Search criterion.

getCorpus

public Corpus getCorpus()
Gets the corpus.

Returns:
The corpus, or null if the set of criteria does not include a corpus criterion.

contains

public boolean contains(java.lang.Class cls)
Returns true if the critera contains a criterion class.

Parameters:
cls - Criterion class.
Returns:
True if the criteria contains a criterion of the specified class.

search

public java.util.List search(org.hibernate.Session session)
                      throws PersistenceException
Executes the query.

Parameters:
session - Hibernate session.
Returns:
A list of all the search results which match the search criteria, ordered by location (by work tag, then by ordinal within work).
Throws:
PersistenceException

getDescription

public TextLine getDescription(FontInfo[] fontInfo)
Gets a description of the search criteria.

Parameters:
fontInfo - Array of font info indexed by character set.
Returns:
Full description of the search criteria, as a multlingual text line of comma-separated clauses.

suspicious

public boolean suspicious()
Returns true if the criteria are "suspicious".

A set of search criteria is "suspicious" if it contains neither a lemma criterion nor a spelling criterion. Such a search is likely to take a long time and produce a large number of results.