View Javadoc

1   /*
2    * ModeShape (http://www.modeshape.org)
3    * See the COPYRIGHT.txt file distributed with this work for information
4    * regarding copyright ownership.  Some portions may be licensed
5    * to Red Hat, Inc. under one or more contributor license agreements.
6    * See the AUTHORS.txt file in the distribution for a full listing of 
7    * individual contributors.
8    *
9    * ModeShape is free software. Unless otherwise indicated, all code in ModeShape
10   * is licensed to you under the terms of the GNU Lesser General Public License as
11   * published by the Free Software Foundation; either version 2.1 of
12   * the License, or (at your option) any later version.
13   * 
14   * ModeShape is distributed in the hope that it will be useful,
15   * but WITHOUT ANY WARRANTY; without even the implied warranty of
16   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   * Lesser General Public License for more details.
18   *
19   * You should have received a copy of the GNU Lesser General Public
20   * License along with this software; if not, write to the Free
21   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23   */
24  package org.modeshape.graph.query.process;
25  
26  import java.util.List;
27  import org.modeshape.common.util.CheckArg;
28  import org.modeshape.graph.Location;
29  import org.modeshape.graph.query.model.Column;
30  
31  /**
32   * A specialization of {@link QueryResultColumns} that can be used to represent results containing only the {@link Location} of
33   * the node and the
34   */
35  public class FullTextSearchResultColumns extends QueryResultColumns {
36  
37      private static final long serialVersionUID = 1L;
38  
39      public static final QueryResultColumns INSTANCE = new FullTextSearchResultColumns();
40  
41      /**
42       * Create a new definition for the query results containing just the locations and the full-text search scores.
43       */
44      public FullTextSearchResultColumns() {
45          super(true, NO_COLUMNS, NO_TYPES);
46      }
47  
48      /**
49       * Create a new definition for the query results given the supplied columns.
50       * 
51       * @param columns the columns that define the results; should never be modified directly
52       * @param columnTypes the type name for each of the Column objects in <code>columns</code>
53       */
54      public FullTextSearchResultColumns( List<Column> columns,
55                                          List<String> columnTypes ) {
56          super(true, columns != null ? columns : NO_COLUMNS, columnTypes != null ? columnTypes : NO_TYPES);
57          CheckArg.isNotEmpty(columns, "columns");
58      }
59  
60      /**
61       * Get the index of a tuple's correct Location object.
62       * 
63       * @return the Location index that corresponds to the supplied column; never negative
64       */
65      public int getLocationIndex() {
66          return getLocationIndex(DEFAULT_SELECTOR_NAME);
67      }
68  
69      /**
70       * Get the index of the tuple value containing the full-text search score for the node.
71       * 
72       * @return the index that corresponds to the {@link Double} full-text search score, or -1 if there is no full-text search
73       *         score for the named selector
74       */
75      public int getFullTextSearchScoreIndex() {
76          return getFullTextSearchScoreIndexFor(DEFAULT_SELECTOR_NAME);
77      }
78  
79      /**
80       * {@inheritDoc}
81       * 
82       * @see org.modeshape.graph.query.process.QueryResultColumns#hasFullTextSearchScores()
83       */
84      @Override
85      public boolean hasFullTextSearchScores() {
86          return true;
87      }
88  }