001
014
015 package com.liferay.portal.kernel.search;
016
017 import java.util.ArrayList;
018 import java.util.List;
019
020
024 public class HitsImpl implements Hits {
025
026 public HitsImpl() {
027 }
028
029 public Document doc(int n) {
030 return _docs[n];
031 }
032
033 public Document[] getDocs() {
034 return _docs;
035 }
036
037 public int getLength() {
038 return _length;
039 }
040
041 public Query getQuery() {
042 return _query;
043 }
044
045 public String[] getQueryTerms() {
046 return _queryTerms;
047 }
048
049 public float[] getScores() {
050 return _scores;
051 }
052
053 public float getSearchTime() {
054 return _searchTime;
055 }
056
057 public String[] getSnippets() {
058 return _snippets;
059 }
060
061 public long getStart() {
062 return _start;
063 }
064
065 public float score(int n) {
066 return _scores[n];
067 }
068
069 public void setDocs(Document[] docs) {
070 _docs = docs;
071 }
072
073 public void setLength(int length) {
074 _length = length;
075 }
076
077 public void setQuery(Query query) {
078 _query = query;
079 }
080
081 public void setQueryTerms(String[] queryTerms) {
082 _queryTerms = queryTerms;
083 }
084
085 public void setScores(float[] scores) {
086 _scores = scores;
087 }
088
089 public void setScores(Float[] scores) {
090 float[] primScores = new float[scores.length];
091
092 for (int i = 0; i < scores.length; i++) {
093 primScores[i] = scores[i].floatValue();
094 }
095
096 setScores(primScores);
097 }
098
099 public void setSearchTime(float time) {
100 _searchTime = time;
101 }
102
103 public void setSnippets(String[] snippets) {
104 _snippets = snippets;
105 }
106
107 public void setStart(long start) {
108 _start = start;
109 }
110
111 public String snippet(int n) {
112 return _snippets[n];
113 }
114
115 public List<Document> toList() {
116 List<Document> subset = new ArrayList<Document>(_docs.length);
117
118 for (Document _doc : _docs) {
119 subset.add(_doc);
120 }
121
122 return subset;
123 }
124
125 private Document[] _docs;
126 private int _length;
127 private Query _query;
128 private String[] _queryTerms;
129 private float[] _scores = new float[0];
130 private float _searchTime;
131 private String[] _snippets = {};
132 private long _start;
133
134 }