01: package net.bagaluten.jca.lucene.connector;
02:
03: import java.io.Serializable;
04: import java.util.Date;
05:
06: public class Field implements Serializable {
07:
08: private static final long serialVersionUID = 1256704739132512039L;
09:
10: public enum Index {
11: NO, NO_NORMS, TOKENIZED, UN_TOKENIZED, UNSET
12: };
13:
14: public enum Store {
15: YES, NO, COMPRESS, UNSET
16: };
17:
18: public enum DateFlag {
19: YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, MILLISECOND, UNSET
20: };
21:
22: private Object data;
23:
24: private Index index;
25:
26: private Store store;
27:
28: private DateFlag dateFlag;
29:
30: public Field(String value, Index idx, Store str) {
31: data = value;
32: index = idx;
33: store = str;
34: dateFlag = DateFlag.UNSET;
35: }
36:
37: public Field(Date value, DateFlag df, Index idx, Store str) {
38: data = value;
39: dateFlag = df;
40: index = idx;
41: store = str;
42: }
43:
44: public Field(Date value) {
45: data = value;
46: index = Index.UNSET;
47: store = Store.UNSET;
48: dateFlag = DateFlag.UNSET;
49: }
50:
51: public Field(String value) {
52: data = value;
53: index = Index.UNSET;
54: store = Store.UNSET;
55: dateFlag = DateFlag.UNSET;
56: }
57:
58: public Index getIndex() {
59: return index;
60: }
61:
62: public Store getStore() {
63: return store;
64: }
65:
66: public DateFlag getDateFlag() {
67: if (!isDate()) {
68: throw new RuntimeException();
69: }
70: return dateFlag;
71: }
72:
73: public Date getDate() {
74: if (!isDate()) {
75: throw new RuntimeException();
76: }
77: return (Date) data;
78: }
79:
80: public String getString() {
81: return data.toString();
82: }
83:
84: public boolean isDate() {
85: return data instanceof Date;
86: }
87: }
|