| HitsImpl.java |
1 /**
2 * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3 *
4 *
5 *
6 *
7 * The contents of this file are subject to the terms of the Liferay Enterprise
8 * Subscription License ("License"). You may not use this file except in
9 * compliance with the License. You can obtain a copy of the License by
10 * contacting Liferay, Inc. See the License for the specific language governing
11 * permissions and limitations under the License, including but not limited to
12 * distribution rights 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 public class HitsImpl implements Hits {
35
36 public HitsImpl() {
37 }
38
39 public long getStart() {
40 return _start;
41 }
42
43 public void setStart(long start) {
44 _start = start;
45 }
46
47 public float getSearchTime() {
48 return _searchTime;
49 }
50
51 public void setSearchTime(float time) {
52 _searchTime = time;
53 }
54
55 public Document[] getDocs() {
56 return _docs;
57 }
58
59 public void setDocs(Document[] docs) {
60 _docs = docs;
61 }
62
63 public int getLength() {
64 return _length;
65 }
66
67 public void setLength(int length) {
68 _length = length;
69 }
70
71 public float[] getScores() {
72 return _scores;
73 }
74
75 public void setScores(float[] scores) {
76 _scores = scores;
77 }
78
79 public void setScores(Float[] scores) {
80 float[] primScores = new float[scores.length];
81
82 for (int i = 0; i < scores.length; i++) {
83 primScores[i] = scores[i].floatValue();
84 }
85
86 setScores(primScores);
87 }
88
89 public Document doc(int n) {
90 return _docs[n];
91 }
92
93 public float score(int n) {
94 return _scores[n];
95 }
96
97 public List<Document> toList() {
98 List<Document> subset = new ArrayList<Document>(_docs.length);
99
100 for (int i = 0; i < _docs.length; i++) {
101 subset.add(_docs[i]);
102 }
103
104 return subset;
105 }
106
107 private long _start;
108 private float _searchTime;
109 private Document[] _docs;
110 private int _length;
111 private float[] _scores = new float[0];
112
113 }