add --shared
[pylucene.git] / lucene-java-3.4.0 / lucene / contrib / instantiated / src / java / org / apache / lucene / store / instantiated / FieldSettings.java
1 package org.apache.lucene.store.instantiated;
2
3 import java.util.HashMap;
4 import java.util.Map;
5 import java.util.Collection;
6 import java.io.Serializable;
7
8 /**
9  * Licensed to the Apache Software Foundation (ASF) under one or more
10  * contributor license agreements.  See the NOTICE file distributed with
11  * this work for additional information regarding copyright ownership.
12  * The ASF licenses this file to You under the Apache License, Version 2.0
13  * (the "License"); you may not use this file except in compliance with
14  * the License.  You may obtain a copy of the License at
15  *
16  *     http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  */
24
25 /**
26  * Essentially a Map<FieldName, {@link org.apache.lucene.store.instantiated.FieldSetting}> 
27  */
28 class FieldSettings implements Serializable {
29
30
31   FieldSettings() {
32   }
33
34   private Map</** field name */String, FieldSetting> fieldSettings = new HashMap<String, FieldSetting>();
35
36   synchronized FieldSetting merge(FieldSetting fieldSetting) {
37     FieldSetting setting = fieldSettings.get(fieldSetting.fieldName);
38
39     if (setting == null) {
40       setting = new FieldSetting(fieldSetting.fieldName);
41       fieldSettings.put(fieldSetting.fieldName, setting);
42     }
43
44     if (fieldSetting.stored) {
45       setting.stored = true;
46     }
47
48     if ("b3".equals(fieldSetting.fieldName)) {
49       System.currentTimeMillis();
50     }
51     if (fieldSetting.indexed) {
52       setting.indexed = true;
53     }
54     if (fieldSetting.tokenized) {
55       setting.tokenized = true;
56     }
57
58     if (fieldSetting.storeTermVector) {
59       setting.storeTermVector = true;
60     }
61     if (fieldSetting.storeOffsetWithTermVector) {
62       setting.storeOffsetWithTermVector = true;
63     }
64     if (fieldSetting.storePositionWithTermVector) {
65       setting.storePositionWithTermVector = true;
66     }
67
68     if (fieldSetting.storePayloads) {
69       setting.storePayloads = true;
70     }
71
72     return setting;
73
74   }
75
76   FieldSetting get(String name) {
77     return fieldSettings.get(name);
78   }
79
80   FieldSetting get(String name, boolean create) {
81     FieldSetting fieldSetting = fieldSettings.get(name);
82     if (create && fieldSetting == null) {
83       fieldSetting = new FieldSetting(name);
84       fieldSettings.put(name, fieldSetting);
85     }
86     return fieldSetting;
87   }
88
89   Collection<FieldSetting> values() {
90     return fieldSettings.values();
91   }
92
93 }