001: /*
002:
003: This software is OSI Certified Open Source Software.
004: OSI Certified is a certification mark of the Open Source Initiative.
005:
006: The license (Mozilla version 1.0) can be read at the MMBase site.
007: See http://www.MMBase.org/license
008:
009: */
010: package org.mmbase.storage.search;
011:
012: import java.util.List;
013: import org.mmbase.module.core.MMObjectBuilder;
014:
015: /**
016: * Defines methods for an object that handles search query requests.
017: *
018: * @author Rob van Maris
019: * @version $Id: SearchQueryHandler.java,v 1.7 2007/11/06 17:12:38 michiel Exp $
020: * @since MMBase-1.7
021: */
022: public interface SearchQueryHandler {
023: /**
024: * Support level for features that are not supported.
025: */
026: public final static int SUPPORT_NONE = 0;
027:
028: /**
029: * Support level for features that are supported, but not recommended when performance is critical.
030: */
031: public final static int SUPPORT_WEAK = 1;
032:
033: /**
034: * Support level for features that are available for use under normal circumstances.
035: */
036: public final static int SUPPORT_NORMAL = 2;
037:
038: /**
039: * Support level for features that are optimally supported. This applies also to features that are supported without a significant impact on performance penalty.
040: */
041: public final static int SUPPORT_OPTIMAL = 3;
042:
043: /**
044: * Feature that allows specifying the maximum number of results to be returned.
045: * @see SearchQuery#getMaxNumber
046: */
047: public final static int FEATURE_MAX_NUMBER = 1;
048:
049: /**
050: * Feature that allows specifying an index in the list of results, as a starting popublic final static int for results to be returned.
051: * @see SearchQuery#getOffset
052: */
053: public final static int FEATURE_OFFSET = 2;
054:
055: /**
056: * Feature that allows to search on string by a regular expression.
057: * @see SearchQuery#getOffset
058: */
059: public final static int FEATURE_REGEXP = 3;
060:
061: /**
062: * Gets the level at which a feature is supported for a query
063: * by this handler. This is one of either:
064: * <ul>
065: * <li>{@link #SUPPORT_NONE SUPPORT_NONE}
066: * <li>{@link #SUPPORT_WEAK SUPPORT_WEAK}
067: * <li>{@link #SUPPORT_NORMAL SUPPORT_NORMAL}
068: * <li>{@link #SUPPORT_OPTIMAL SUPPORT_OPTIMAL}
069: * </ul>
070: * Given the choice, the query handler with the highest level of support is prefered.
071: */
072: public int getSupportLevel(int feature, SearchQuery query)
073: throws SearchQueryException;
074:
075: /**
076: * Gets the level at which a constraint is supported for a query
077: * by this handler. This is one of either:
078: * <ul>
079: * <li>{@link #SUPPORT_NONE SUPPORT_NONE}
080: * <li>{@link #SUPPORT_WEAK SUPPORT_WEAK}
081: * <li>{@link #SUPPORT_NORMAL SUPPORT_NORMAL}
082: * <li>{@link #SUPPORT_OPTIMAL SUPPORT_OPTIMAL}
083: * </ul>
084: * Given the choice, the query handler with the highest level of support is prefered.
085: */
086: public int getSupportLevel(Constraint constraint, SearchQuery query)
087: throws SearchQueryException;
088:
089: /**
090: * Processes a search query, returns the result as a list of nodes.
091: * Depending on the specified builder, the results will be:
092: * <ul>
093: * <li>Resultnodes, with fields named according to the field aliases
094: * specified by the query.
095: * <li>Clusternodes, with fields named
096: * <code><step alias>.<field name></code>, where
097: * the step alias is required to be of the form
098: * <code><step tablename><x></code>, and
099: * <code><x></code> is either empty or a single digit. Examples: <br />
100: * <code>images.number</code>, <code>images0.number</code>,
101: * <code>images1.number</code>
102: * <li>Real nodes, where all fields are required to be included in
103: * the query.
104: * </ul>
105: * @param query The search query.
106: * @param builder The builder for the result nodes. Specify a
107: * {@link ResultBuilder ResultBuilder}
108: * to get resultnodes.
109: * {@link org.mmbase.module.core.ClusterBuilder ClusterBuilder}
110: * to get clusternodes.
111: * @return The resulting nodes.
112: * @see ResultNode
113: * @see org.mmbase.module.core.ClusterNode
114: */
115: public List<org.mmbase.module.core.MMObjectNode> getNodes(
116: SearchQuery query, MMObjectBuilder builder)
117: throws SearchQueryException;
118:
119: /**
120: * Makes a String of a query, taking into consideration if the database supports offset and
121: * maxnumber features. The resulting String is an SQL query which can be fed to the database.
122: * @param query the query to convert to sql
123: * @return the sql string
124: * @throws SearchQueryException when error occurs while making the string
125: * @since MMBase-1.8.5
126: */
127: public String createSqlString(SearchQuery query)
128: throws SearchQueryException;
129:
130: }
|