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.
19 import java.util.ArrayList;
20 import java.util.List;
23 * Class to hold multiple SinglePhraseQueries and/or other CompoundQueries.
25 * @author Edwin Punzalan
27 public class CompoundQuery
33 private final List compoundQueryTerms = new ArrayList();
36 * Appends a required term to this query.
38 * @param term the term to be appended to this query
40 public void and( QueryTerm term )
42 compoundQueryTerms.add( CompoundQueryTerm.and( new SingleTermQuery( term ) ) );
46 * Appends an optional term to this query.
48 * @param term the term to be appended to this query
50 public void or( QueryTerm term )
52 compoundQueryTerms.add( CompoundQueryTerm.or( new SingleTermQuery( term ) ) );
56 * Appends a prohibited term to this query.
58 * @param term the term to be appended to this query
60 public void not( QueryTerm term )
62 compoundQueryTerms.add( CompoundQueryTerm.not( new SingleTermQuery( term ) ) );
66 * Appends a required subquery to this query.
68 * @param query the subquery to be appended to this query
70 public void and( Query query )
72 compoundQueryTerms.add( CompoundQueryTerm.and( query ) );
76 * Appends an optional subquery to this query.
78 * @param query the subquery to be appended to this query
80 public void or( Query query )
82 compoundQueryTerms.add( CompoundQueryTerm.or( query ) );
86 * Appends a prohibited subquery to this query.
88 * @param query the subquery to be appended to this query
90 public void not( Query query )
92 compoundQueryTerms.add( CompoundQueryTerm.not( query ) );
96 * Method to get the List of Queries appended into this
98 * @return List of all Queries added to this Query
100 public List getCompoundQueryTerms()
102 return compoundQueryTerms;