1
22
23 package com.liferay.portal.kernel.search;
24
25 import java.util.ArrayList;
26 import java.util.List;
27
28
34 public class HitsImpl implements Hits {
35
36 public HitsImpl() {
37 }
38
39 public Document doc(int n) {
40 return _docs[n];
41 }
42
43 public Document[] getDocs() {
44 return _docs;
45 }
46
47 public int getLength() {
48 return _length;
49 }
50
51 public String[] getQueryTerms() {
52 return _queryTerms;
53 }
54
55 public float[] getScores() {
56 return _scores;
57 }
58
59 public float getSearchTime() {
60 return _searchTime;
61 }
62
63 public String[] getSnippets() {
64 return _snippets;
65 }
66
67 public long getStart() {
68 return _start;
69 }
70
71 public float score(int n) {
72 return _scores[n];
73 }
74
75 public void setDocs(Document[] docs) {
76 _docs = docs;
77 }
78
79 public void setLength(int length) {
80 _length = length;
81 }
82
83 public void setQueryTerms(String[] queryTerms) {
84 _queryTerms = queryTerms;
85 }
86
87 public void setScores(float[] scores) {
88 _scores = scores;
89 }
90
91 public void setScores(Float[] scores) {
92 float[] primScores = new float[scores.length];
93
94 for (int i = 0; i < scores.length; i++) {
95 primScores[i] = scores[i].floatValue();
96 }
97
98 setScores(primScores);
99 }
100
101 public void setSearchTime(float time) {
102 _searchTime = time;
103 }
104
105 public void setSnippets(String[] snippets) {
106 _snippets = snippets;
107 }
108
109 public void setStart(long start) {
110 _start = start;
111 }
112
113 public String snippet(int n) {
114 return _snippets[n];
115 }
116
117 public List<Document> toList() {
118 List<Document> subset = new ArrayList<Document>(_docs.length);
119
120 for (int i = 0; i < _docs.length; i++) {
121 subset.add(_docs[i]);
122 }
123
124 return subset;
125 }
126
127 private Document[] _docs;
128 private int _length;
129 private String[] _queryTerms;
130 private float[] _scores = new float[0];
131 private float _searchTime;
132 private String[] _snippets;
133 private long _start;
134
135 }