| HitsImpl.java |
1 /**
2 * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 package com.liferay.portal.kernel.search;
24
25 import java.util.ArrayList;
26 import java.util.List;
27
28 /**
29 * <a href="HitsImpl.java.html"><b><i>View Source</i></b></a>
30 *
31 * @author Brian Wing Shun Chan
32 * @author Bruno Farache
33 *
34 */
35 public class HitsImpl implements Hits {
36
37 public HitsImpl() {
38 }
39
40 public long getStart() {
41 return _start;
42 }
43
44 public void setStart(long start) {
45 _start = start;
46 }
47
48 public float getSearchTime() {
49 return _searchTime;
50 }
51
52 public void setSearchTime(float time) {
53 _searchTime = time;
54 }
55
56 public Document[] getDocs() {
57 return _docs;
58 }
59
60 public void setDocs(Document[] docs) {
61 _docs = docs;
62 }
63
64 public int getLength() {
65 return _length;
66 }
67
68 public void setLength(int length) {
69 _length = length;
70 }
71
72 public float[] getScores() {
73 return _scores;
74 }
75
76 public void setScores(float[] scores) {
77 _scores = scores;
78 }
79
80 public void setScores(Float[] scores) {
81 float[] primScores = new float[scores.length];
82
83 for (int i = 0; i < scores.length; i++) {
84 primScores[i] = scores[i].floatValue();
85 }
86
87 setScores(primScores);
88 }
89
90 public Document doc(int n) {
91 return _docs[n];
92 }
93
94 public float score(int n) {
95 return _scores[n];
96 }
97
98 public List<Document> toList() {
99 List<Document> subset = new ArrayList<Document>(_docs.length);
100
101 for (int i = 0; i < _docs.length; i++) {
102 subset.add(_docs[i]);
103 }
104
105 return subset;
106 }
107
108 private long _start;
109 private float _searchTime;
110 private Document[] _docs;
111 private int _length;
112 private float[] _scores = new float[0];
113
114 }