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 this( ontology, version, key, description, storeMethod, indexMethod, null );
51 }
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 {
57 this.ontology = ontology;
58
59 this.version = version;
60
61 this.key = key;
62
63 this.storeMethod = storeMethod;
64
65 this.indexMethod = indexMethod;
66
67 this.termVector = termVector;
68
69 ontology.addIndexerField( this );
70 }
71
72 public org.apache.maven.index.Field getOntology()
73 {
74 return ontology;
75 }
76
77 public IndexerFieldVersion getVersion()
78 {
79 return version;
80 }
81
82 public String getKey()
83 {
84 return key;
85 }
86
87 public Field.Store getStoreMethod()
88 {
89 return storeMethod;
90 }
91
92 public Field.Index getIndexMethod()
93 {
94 return indexMethod;
95 }
96
97 public Field.TermVector getTermVector()
98 {
99 return termVector;
100 }
101
102 public boolean isIndexed()
103 {
104 return !Index.NO.equals( indexMethod );
105 }
106
107 public boolean isKeyword()
108 {
109 return isIndexed() && !Index.ANALYZED.equals( indexMethod );
110 }
111
112 public boolean isStored()
113 {
114 return !( Store.NO.equals( storeMethod ) );
115 }
116
117 public Field toField( String value )
118 {
119 Field result;
120
121 if ( getTermVector() != null )
122 {
123 result = new Field( getKey(), value, getStoreMethod(), getIndexMethod(), getTermVector() );
124 }
125 else
126 {
127 result = new Field( getKey(), value, getStoreMethod(), getIndexMethod() );
128 }
129
130
131
132
133
134
135
136 return result;
137 }
138 }