1 package org.apache.maven.repository.indexing.query;
4 * Copyright 2005-2006 The Apache Software Foundation.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 * Base of all query terms.
22 * @author <a href="mailto:brett@apache.org">Brett Porter</a>
24 public class CompoundQueryTerm
27 * The query to add to the compound query.
29 private final Query query;
32 * Whether the term is required (an AND).
34 private final boolean required;
37 * Whether the term is prohibited (a NOT).
39 private final boolean prohibited;
44 * @param query the subquery to add
45 * @param required whether the term is required (an AND)
46 * @param prohibited whether the term is prohibited (a NOT)
48 private CompoundQueryTerm( Query query, boolean required, boolean prohibited )
51 this.prohibited = prohibited;
52 this.required = required;
56 * Method to test if the Query is a search requirement
58 * @return true if this Query is a search requirement, otherwise returns false
60 public boolean isRequired()
66 * Method to test if the Query is prohibited in the search result
68 * @return true if this Query is prohibited in the search result
70 public boolean isProhibited()
77 * The subquery to execute.
81 public Query getQuery()
86 static CompoundQueryTerm and( Query query )
88 return new CompoundQueryTerm( query, true, false );
91 static CompoundQueryTerm or( Query query )
93 return new CompoundQueryTerm( query, false, false );
96 static CompoundQueryTerm not( Query query )
98 return new CompoundQueryTerm( query, false, true );