1 | |
package org.apache.maven.index; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.lucene.document.Field; |
23 | |
import org.apache.lucene.document.Field.Index; |
24 | |
import org.apache.lucene.document.Field.Store; |
25 | |
import org.apache.lucene.document.Field.TermVector; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
public class IndexerField |
34 | |
{ |
35 | |
private final org.apache.maven.index.Field ontology; |
36 | |
|
37 | |
private final IndexerFieldVersion version; |
38 | |
|
39 | |
private final String key; |
40 | |
|
41 | |
private final Store storeMethod; |
42 | |
|
43 | |
private final Index indexMethod; |
44 | |
|
45 | |
private final TermVector termVector; |
46 | |
|
47 | |
public IndexerField( final org.apache.maven.index.Field ontology, final IndexerFieldVersion version, |
48 | |
final String key, final String description, final Store storeMethod, final Index indexMethod ) |
49 | |
{ |
50 | 29 | this( ontology, version, key, description, storeMethod, indexMethod, null ); |
51 | 29 | } |
52 | |
|
53 | |
public IndexerField( final org.apache.maven.index.Field ontology, final IndexerFieldVersion version, |
54 | |
final String key, final String description, final Store storeMethod, final Index indexMethod, |
55 | |
final TermVector termVector ) |
56 | 29 | { |
57 | 29 | this.ontology = ontology; |
58 | |
|
59 | 29 | this.version = version; |
60 | |
|
61 | 29 | this.key = key; |
62 | |
|
63 | 29 | this.storeMethod = storeMethod; |
64 | |
|
65 | 29 | this.indexMethod = indexMethod; |
66 | |
|
67 | 29 | this.termVector = termVector; |
68 | |
|
69 | 29 | ontology.addIndexerField( this ); |
70 | 29 | } |
71 | |
|
72 | |
public org.apache.maven.index.Field getOntology() |
73 | |
{ |
74 | 4611 | return ontology; |
75 | |
} |
76 | |
|
77 | |
public IndexerFieldVersion getVersion() |
78 | |
{ |
79 | 0 | return version; |
80 | |
} |
81 | |
|
82 | |
public String getKey() |
83 | |
{ |
84 | 361116 | return key; |
85 | |
} |
86 | |
|
87 | |
public Field.Store getStoreMethod() |
88 | |
{ |
89 | 288696 | return storeMethod; |
90 | |
} |
91 | |
|
92 | |
public Field.Index getIndexMethod() |
93 | |
{ |
94 | 288696 | return indexMethod; |
95 | |
} |
96 | |
|
97 | |
public Field.TermVector getTermVector() |
98 | |
{ |
99 | 288696 | return termVector; |
100 | |
} |
101 | |
|
102 | |
public boolean isIndexed() |
103 | |
{ |
104 | 19123 | return !Index.NO.equals( indexMethod ); |
105 | |
} |
106 | |
|
107 | |
public boolean isKeyword() |
108 | |
{ |
109 | 14290 | return isIndexed() && !Index.ANALYZED.equals( indexMethod ); |
110 | |
} |
111 | |
|
112 | |
public boolean isStored() |
113 | |
{ |
114 | 2 | return !( Store.NO.equals( storeMethod ) ); |
115 | |
} |
116 | |
|
117 | |
public Field toField( String value ) |
118 | |
{ |
119 | |
Field result; |
120 | |
|
121 | 288696 | if ( getTermVector() != null ) |
122 | |
{ |
123 | 0 | result = new Field( getKey(), value, getStoreMethod(), getIndexMethod(), getTermVector() ); |
124 | |
} |
125 | |
else |
126 | |
{ |
127 | 288696 | result = new Field( getKey(), value, getStoreMethod(), getIndexMethod() ); |
128 | |
} |
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | 288696 | return result; |
137 | |
} |
138 | |
} |