View Javadoc

1   package org.apache.maven.index;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0    
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.Arrays;
23  import java.util.Comparator;
24  
25  import org.apache.lucene.search.Query;
26  import org.apache.maven.index.context.IndexingContext;
27  
28  /**
29   * A grouped search request. This kinds of request is not pageable, since order of incoming hits are not defined, hence
30   * paging between Document hits makes no sense, would produce unpredictable (and probably not meaningful) results.
31   * 
32   * @see Indexer#searchGrouped(GroupedSearchRequest)
33   */
34  public class GroupedSearchRequest
35      extends AbstractSearchRequest
36  {
37      private Grouping grouping;
38  
39      private Comparator<String> groupKeyComparator;
40  
41      public GroupedSearchRequest( Query query, Grouping grouping )
42      {
43          this( query, grouping, String.CASE_INSENSITIVE_ORDER );
44      }
45  
46      public GroupedSearchRequest( Query query, Grouping grouping, Comparator<String> groupKeyComparator )
47      {
48          this( query, grouping, groupKeyComparator, null );
49      }
50  
51      public GroupedSearchRequest( Query query, Grouping grouping, IndexingContext context )
52      {
53          this( query, grouping, String.CASE_INSENSITIVE_ORDER, context );
54      }
55  
56      public GroupedSearchRequest( Query query, Grouping grouping, Comparator<String> groupKeyComparator,
57                                   IndexingContext context )
58      {
59          super( query, context != null ? Arrays.asList( new IndexingContext[] { context } ) : null );
60  
61          this.grouping = grouping;
62  
63          this.groupKeyComparator = groupKeyComparator;
64      }
65  
66      public Grouping getGrouping()
67      {
68          return grouping;
69      }
70  
71      public void setGrouping( Grouping grouping )
72      {
73          this.grouping = grouping;
74      }
75  
76      public Comparator<String> getGroupKeyComparator()
77      {
78          return groupKeyComparator;
79      }
80  
81      public void setGroupKeyComparator( Comparator<String> groupKeyComparator )
82      {
83          this.groupKeyComparator = groupKeyComparator;
84      }
85  }