1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.kernel.search;
21  
22  import java.util.ArrayList;
23  import java.util.List;
24  
25  /**
26   * <a href="HitsImpl.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   * @author Bruno Farache
30   *
31   */
32  public class HitsImpl implements Hits {
33  
34      public HitsImpl() {
35      }
36  
37      public long getStart() {
38          return _start;
39      }
40  
41      public void setStart(long start) {
42          _start = start;
43      }
44  
45      public float getSearchTime() {
46          return _searchTime;
47      }
48  
49      public void setSearchTime(float time) {
50          _searchTime = time;
51      }
52  
53      public Document[] getDocs() {
54          return _docs;
55      }
56  
57      public void setDocs(Document[] docs) {
58          _docs = docs;
59      }
60  
61      public int getLength() {
62          return _length;
63      }
64  
65      public void setLength(int length) {
66          _length = length;
67      }
68  
69      public float[] getScores() {
70          return _scores;
71      }
72  
73      public void setScores(float[] scores) {
74          _scores = scores;
75      }
76  
77      public void setScores(Float[] scores) {
78          float[] primScores = new float[scores.length];
79  
80          for (int i = 0; i < scores.length; i++) {
81              primScores[i] = scores[i].floatValue();
82          }
83  
84          setScores(primScores);
85      }
86  
87      public Document doc(int n) {
88          return _docs[n];
89      }
90  
91      public float score(int n) {
92          return _scores[n];
93      }
94  
95      public List<Document> toList() {
96          List<Document> subset = new ArrayList<Document>(_docs.length);
97  
98          for (int i = 0; i < _docs.length; i++) {
99              subset.add(_docs[i]);
100         }
101 
102         return subset;
103     }
104 
105     private long _start;
106     private float _searchTime;
107     private Document[] _docs;
108     private int _length;
109     private float[] _scores = new float[0];
110 
111 }