001: /*
002: * Copyright 2004-2006 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.compass.core;
018:
019: /**
020: * The query builder is used to construct
021: * {@link CompassQueryFilter} programmatically. Simple
022: * queries, like {@link #le(String, Object)}, will generate a
023: * {@link CompassQueryFilter}. More complex ones, will
024: * return their repective builder to continue and bulid them (like
025: * {@link #bool()}).
026: * <p/>
027: * The generated filter can be set on the query itself using {@link CompassQuery#setFilter(CompassQueryFilter)}.
028: *
029: * @author kimchy
030: */
031: public interface CompassQueryFilterBuilder {
032:
033: /**
034: * A general interface for internal builders that will create a
035: * {@link CompassQueryFilter}.
036: *
037: * @author kimchy
038: */
039: public static interface ToCompassQueryFilter {
040:
041: CompassQueryFilter toFilter();
042: }
043:
044: /**
045: * A boolean query filter builder. Used to construct query filter that will return hits
046: * that are the matching boolean combinations of other queries.
047: *
048: * @author kimchy
049: */
050: public static interface CompassBooleanQueryFilterBuilder extends
051: ToCompassQueryFilter {
052:
053: CompassBooleanQueryFilterBuilder and(CompassQueryFilter filter);
054:
055: CompassBooleanQueryFilterBuilder or(CompassQueryFilter filter);
056:
057: CompassBooleanQueryFilterBuilder andNot(
058: CompassQueryFilter filter);
059:
060: CompassBooleanQueryFilterBuilder xor(CompassQueryFilter filter);
061: }
062:
063: /**
064: * Creates a query filter where the resource proeprty is between the given values.
065: * <p/>
066: * The name can either be the actual resource property or meta-data value,
067: * or the path to the given resource property (alias.rProperty), or the
068: * class property (alias.cProperty) or the path to the meta-data
069: * (alias.cProperty.metaData)
070: *
071: * @param name The resource property name
072: * @param low The low value limit
073: * @param high The high value limit
074: * @param includeLow Include the lower value
075: * @param includeHigh Include the high value
076: * @return The query filter
077: */
078: CompassQueryFilter between(String name, Object low, Object high,
079: boolean includeLow, boolean includeHigh);
080:
081: /**
082: * Creates a query filter where the resource proeprty is less than (<) the given
083: * value.
084: * <p/>
085: * The name can either be the actual resource property or meta-data value,
086: * or the path to the given resource property (alias.rProperty), or the
087: * class property (alias.cProperty) or the path to the meta-data
088: * (alias.cProperty.metaData)
089: *
090: * @param name The resource property name
091: * @param value The high limit value
092: * @return The generated query filter
093: */
094: CompassQueryFilter lt(String name, Object value);
095:
096: /**
097: * Creates a query filter where the resource proeprty is less or equal (<=) to the
098: * given value.
099: * <p/>
100: * The name can either be the actual resource property or meta-data value,
101: * or the path to the given resource property (alias.rProperty), or the
102: * class property (alias.cProperty) or the path to the meta-data
103: * (alias.cProperty.metaData)
104: *
105: * @param name The resource property name
106: * @param value The high limit value
107: * @return The generated query filter
108: */
109: CompassQueryFilter le(String name, Object value);
110:
111: /**
112: * Creates a query filter where the resource proeprty is greater than (>) to the
113: * given value.
114: * <p/>
115: * The name can either be the actual resource property or meta-data value,
116: * or the path to the given resource property (alias.rProperty), or the
117: * class property (alias.cProperty) or the path to the meta-data
118: * (alias.cProperty.metaData)
119: *
120: * @param name The resource property name
121: * @param value The low limit value
122: * @return The generated query filter
123: */
124: CompassQueryFilter gt(String name, Object value);
125:
126: /**
127: * Creates a query filter where the resource proeprty is greater or equal (>=) to
128: * the given value.
129: * <p/>
130: * The name can either be the actual resource property or meta-data value,
131: * or the path to the given resource property (alias.rProperty), or the
132: * class property (alias.cProperty) or the path to the meta-data
133: * (alias.cProperty.metaData)
134: *
135: * @param name The resource property name
136: * @param value The low limit value
137: * @return The generated query filter
138: */
139: CompassQueryFilter ge(String name, Object value);
140:
141: /**
142: * Creates a query filter that is based on the given compass query.
143: *
144: * @param query The query to filter by.
145: * @return The query filter.
146: */
147: CompassQueryFilter query(CompassQuery query);
148:
149: /**
150: * Creates a boolean query filter builder.
151: *
152: * @return The boolean query filter builder
153: */
154: CompassBooleanQueryFilterBuilder bool();
155: }
|