1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| package org.apache.xindice.core.query.ftsearch; |
21 |
| |
22 |
| import org.apache.lucene.index.TermEnum; |
23 |
| import org.apache.lucene.index.Term; |
24 |
| |
25 |
| import java.util.Iterator; |
26 |
| import java.util.SortedMap; |
27 |
| import java.util.HashSet; |
28 |
| import java.util.List; |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| public class NodeTermEnum extends TermEnum { |
36 |
| |
37 |
| private SortedMap termMap; |
38 |
| |
39 |
| private Iterator iterator; |
40 |
| |
41 |
| |
42 |
| private String curTerm; |
43 |
| |
44 |
11
| public NodeTermEnum(SortedMap termMap) {
|
45 |
11
| this.termMap = termMap;
|
46 |
11
| iterator = this.termMap.keySet().iterator();
|
47 |
11
| if (iterator.hasNext()) {
|
48 |
11
| curTerm = (String) iterator.next();
|
49 |
| } |
50 |
| } |
51 |
| |
52 |
11
| public NodeTermEnum(SortedMap termMap, Term t) {
|
53 |
11
| this(termMap.tailMap(t.text()));
|
54 |
| } |
55 |
| |
56 |
84
| public boolean next() {
|
57 |
84
| if (iterator.hasNext()) {
|
58 |
83
| curTerm = (String) iterator.next();
|
59 |
83
| return true;
|
60 |
| } |
61 |
| |
62 |
1
| return false;
|
63 |
| } |
64 |
| |
65 |
94
| public Term term() {
|
66 |
94
| if (curTerm != null) {
|
67 |
94
| return new Term("", curTerm);
|
68 |
| } |
69 |
| |
70 |
0
| return null;
|
71 |
| } |
72 |
| |
73 |
0
| public int docFreq() {
|
74 |
0
| List docs = (List) termMap.get(curTerm);
|
75 |
| |
76 |
0
| HashSet set = new HashSet();
|
77 |
0
| set.addAll(docs);
|
78 |
0
| return set.size();
|
79 |
| } |
80 |
| |
81 |
| |
82 |
| |
83 |
| |
84 |
11
| public void close() {
|
85 |
| } |
86 |
| } |