com.binaryfantasy.murq.search
Class MurqQuery

java.lang.Object
  extended by com.binaryfantasy.murq.search.MurqQuery

public class MurqQuery
extends Object

A MurqQuery represents critera for content to be returned from Murq. The results obtained are based on both built-in indexing as well as locale information and developer defined index properties.

Author:
Bill Weiss

Method Summary
 MurqQuery addClassTerm(Class clazz, boolean exclude)
          Adds the clazz to this query, checking that content is assignment-compatible.
 MurqQuery addContentIdTerm(String contentId, boolean exclude)
          Adds the contentId to this query, checking that content has the contentId specified.
 MurqQuery addDateCreatedTerm(Date created, boolean exclude)
          Adds the created to this query, checking that content was created on the created date specified.
 MurqQuery addDateModifiedTerm(Date modified, boolean exclude)
          Adds the modified to this query, checking that content was modified on the modified date specified.
 MurqQuery addKeywordTerm(String property, String keyword, boolean exclude)
          Adds a keyword value that must be matched exactly, including or excluding the results based on the value of exclude.
 MurqQuery addLocaleTerm(Locale locale, boolean exclude)
          Adds the locale to this query, checking that content is of the locale specified.
 MurqQuery addQuery(org.apache.lucene.search.Query query, boolean exclude)
          Adds the query to this query, including or excluding it's results based on the value of exclude.
 MurqQuery addQuery(String queryStr, boolean exclude)
          Adds the queryStr to this query, including or excluding it's results based on the value of exclude.
 MurqQuery addRangedDateCreatedTerm(Date from, Date to, boolean inclusive, boolean exclude)
          Adds a creation date range to this query, checking that content was created within the date range specified.
 MurqQuery addRangedDateModifiedTerm(Date from, Date to, boolean inclusive, boolean exclude)
          Adds a modification date range to this query, checking that content was modified within the date range specified.
 MurqQuery addRangedKeywordTerm(String property, String from, String to, boolean inclusive, boolean exclude)
          Adds a keyword value that must fall between the from and to values, including or excluding the results based on the value of exclude.
 MurqQuery allLocales()
          Sets this query to ignore locale filtering and return all matching content, even content differing only by locale.
static MurqQuery create()
          Creates and returns a new, unconfigured, MurqQuery.
 Comparator<IContent> getComparator()
          Returns the Comparator to be used for result ordering, or null to use Lucene relavance ordering.
 Locale getLocale()
          Returns the Locale for use in localization, or null if default or no localization is to be done.
 org.apache.lucene.search.Query getQuery()
          Returns the Lucene Query resulting from this object's configuration.
 boolean isLocalized()
          Return true if results will be localized.
 MurqQuery locale(Locale locale)
          Set the Locale that results should be appropriate for, based on the method outlined in the ResourceBundle.getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader) method.
 MurqQuery localize()
          Sets this query filter content for locale appropriateness, based on the method outlined in the ResourceBundle.getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader) method.
 MurqQuery orderBy(Comparator<IContent> orderBy)
          Sets the Comparator to be used to order results.
 MurqQuery orderBy(String orderBy)
          Sets the property to be compared when ordering results.
 MurqQuery orderBy(String[] orderBy)
          Sets the priority of properties to be compared when ordering results.
 MurqQuery orderBy(String[] orderBy, boolean desc)
          Sets the priority of properties to be compared when ordering results.
 MurqQuery orderBy(String orderBy, boolean desc)
          Sets the property to be compared when ordering results.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static MurqQuery create()
Creates and returns a new, unconfigured, MurqQuery.

Returns:
a new, unconfigured, MurqQuery.

addQuery

public MurqQuery addQuery(String queryStr,
                          boolean exclude)
Adds the queryStr to this query, including or excluding it's results based on the value of exclude.

Parameters:
queryStr - the query to be parsed and added.
exclude - true to ensure that matching data is NOT returned.
Returns:
a reference to this object.

addQuery

public MurqQuery addQuery(org.apache.lucene.search.Query query,
                          boolean exclude)
Adds the query to this query, including or excluding it's results based on the value of exclude.

Parameters:
query - the query to be added.
exclude - true to ensure that matching data is NOT returned.
Returns:
a reference to this object.

addKeywordTerm

public MurqQuery addKeywordTerm(String property,
                                String keyword,
                                boolean exclude)
Adds a keyword value that must be matched exactly, including or excluding the results based on the value of exclude.

Parameters:
property - the name of the content property whose value the keyword should match.
keyword - the value required for a match.
exclude - true to ensure that matching data is NOT returned.
Returns:
a reference to this object.

addRangedKeywordTerm

public MurqQuery addRangedKeywordTerm(String property,
                                      String from,
                                      String to,
                                      boolean inclusive,
                                      boolean exclude)
Adds a keyword value that must fall between the from and to values, including or excluding the results based on the value of exclude.

Parameters:
property - the name of the content property whose value the keyword range should match.
from - the minimum value required for a match.
to - the maximum value required for a match.
inclusive - true if values matching the to and from should be considered a match.
exclude - true to ensure that matching data is NOT returned.
Returns:
a reference to this object.

addClassTerm

public MurqQuery addClassTerm(Class clazz,
                              boolean exclude)
Adds the clazz to this query, checking that content is assignment-compatible.

Parameters:
clazz - the clazz to use for assignment-compatible comparison.
exclude - true to ensure that matching data is NOT returned.
Returns:
a reference to this object.

addLocaleTerm

public MurqQuery addLocaleTerm(Locale locale,
                               boolean exclude)
Adds the locale to this query, checking that content is of the locale specified.

Parameters:
locale - the locale to be matched.
exclude - true to ensure that matching data is NOT returned.
Returns:
a reference to this object.

addContentIdTerm

public MurqQuery addContentIdTerm(String contentId,
                                  boolean exclude)
Adds the contentId to this query, checking that content has the contentId specified.

Parameters:
contentId - the contentId to be matched.
exclude - true to ensure that matching data is NOT returned.
Returns:
a reference to this object.

addDateCreatedTerm

public MurqQuery addDateCreatedTerm(Date created,
                                    boolean exclude)
Adds the created to this query, checking that content was created on the created date specified.

Parameters:
created - the creation date to be matched.
exclude - true to ensure that matching data is NOT returned.
Returns:
a reference to this object.

addRangedDateCreatedTerm

public MurqQuery addRangedDateCreatedTerm(Date from,
                                          Date to,
                                          boolean inclusive,
                                          boolean exclude)
Adds a creation date range to this query, checking that content was created within the date range specified.

Parameters:
from - earliest creation date.
to - latest creation date.
inclusive - true if values matching the to and from should be considered a match.
exclude - true to ensure that matching data is NOT returned.
Returns:
a reference to this object.

addDateModifiedTerm

public MurqQuery addDateModifiedTerm(Date modified,
                                     boolean exclude)
Adds the modified to this query, checking that content was modified on the modified date specified.

Parameters:
modified - the modification date to be matched.
exclude - true to ensure that matching data is NOT returned.
Returns:
a reference to this object.

addRangedDateModifiedTerm

public MurqQuery addRangedDateModifiedTerm(Date from,
                                           Date to,
                                           boolean inclusive,
                                           boolean exclude)
Adds a modification date range to this query, checking that content was modified within the date range specified.

Parameters:
from - earliest modification date.
to - latest modification date.
inclusive - true if values matching the to and from should be considered a match.
exclude - true to ensure that matching data is NOT returned.
Returns:
a reference to this object.

locale

public MurqQuery locale(Locale locale)
Set the Locale that results should be appropriate for, based on the method outlined in the ResourceBundle.getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader) method.

Parameters:
locale - the most appropriate locale for results.
Returns:
a reference to this object.

localize

public MurqQuery localize()
Sets this query filter content for locale appropriateness, based on the method outlined in the ResourceBundle.getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader) method.

NOTE: This disables allLocales().

Returns:
a reference to this object.

allLocales

public MurqQuery allLocales()
Sets this query to ignore locale filtering and return all matching content, even content differing only by locale.

NOTE: This disables localize().

Returns:
a reference to this object.

orderBy

public MurqQuery orderBy(Comparator<IContent> orderBy)
Sets the Comparator to be used to order results.

Parameters:
orderBy - the Comparator to be used to order results.
Returns:
a reference to this object.

orderBy

public MurqQuery orderBy(String[] orderBy,
                         boolean desc)
Sets the priority of properties to be compared when ordering results.

Parameters:
orderBy - the priority of properties to be compared when ordering results.
desc - true if ordering should be reversed.
Returns:
a reference to this object.

orderBy

public MurqQuery orderBy(String orderBy,
                         boolean desc)
Sets the property to be compared when ordering results.

Parameters:
orderBy - the property to be compared when ordering results.
desc - true if ordering should be reversed.
Returns:
a reference to this object.

orderBy

public MurqQuery orderBy(String[] orderBy)
Sets the priority of properties to be compared when ordering results.

Parameters:
orderBy - the priority of properties to be compared when ordering results.
Returns:
a reference to this object.

orderBy

public MurqQuery orderBy(String orderBy)
Sets the property to be compared when ordering results.

Parameters:
orderBy - the property to be compared when ordering results.
Returns:
a reference to this object.

getQuery

public org.apache.lucene.search.Query getQuery()
Returns the Lucene Query resulting from this object's configuration.

Returns:
the Lucene Query resulting from this object's configuration.

getLocale

public Locale getLocale()
Returns the Locale for use in localization, or null if default or no localization is to be done.

Returns:
the Locale for use in localization, or null if default or no localization is to be done.

getComparator

public Comparator<IContent> getComparator()
Returns the Comparator to be used for result ordering, or null to use Lucene relavance ordering.

Returns:
the Comparator to be used for result ordering, or null to use Lucene relavance ordering.

isLocalized

public boolean isLocalized()
Return true if results will be localized.

Returns:
true if results will be localized.


Copyright (c) 2000-2006, BinaryFantasy.com