Lucene.Net  3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
FieldInfo.cs
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 using System;
19 
20 namespace Lucene.Net.Index
21 {
22 
23  public sealed class FieldInfo : System.ICloneable
24  {
25  internal System.String name;
26  internal bool isIndexed;
27  internal int number;
28 
29  // true if term vector for this field should be stored
30  internal bool storeTermVector;
31  internal bool storeOffsetWithTermVector;
32  internal bool storePositionWithTermVector;
33 
34  internal bool omitNorms; // omit norms associated with indexed fields
35  internal bool omitTermFreqAndPositions;
36 
37  internal bool storePayloads; // whether this field stores payloads together with term positions
38 
39  internal FieldInfo(System.String na, bool tk, int nu, bool storeTermVector, bool storePositionWithTermVector, bool storeOffsetWithTermVector, bool omitNorms, bool storePayloads, bool omitTermFreqAndPositions)
40  {
41  name = na;
42  isIndexed = tk;
43  number = nu;
44  if (isIndexed)
45  {
46  this.storeTermVector = storeTermVector;
47  this.storeOffsetWithTermVector = storeOffsetWithTermVector;
48  this.storePositionWithTermVector = storePositionWithTermVector;
49  this.storePayloads = storePayloads;
50  this.omitNorms = omitNorms;
51  this.omitTermFreqAndPositions = omitTermFreqAndPositions;
52  }
53  else
54  {
55  // for non-indexed fields, leave defaults
56  this.storeTermVector = false;
57  this.storeOffsetWithTermVector = false;
58  this.storePositionWithTermVector = false;
59  this.storePayloads = false;
60  this.omitNorms = true;
61  this.omitTermFreqAndPositions = false;
62  }
63  }
64 
65  public System.Object Clone()
66  {
67  return new FieldInfo(name, isIndexed, number, storeTermVector, storePositionWithTermVector, storeOffsetWithTermVector, omitNorms, storePayloads, omitTermFreqAndPositions);
68  }
69 
70  internal void Update(bool isIndexed, bool storeTermVector, bool storePositionWithTermVector, bool storeOffsetWithTermVector, bool omitNorms, bool storePayloads, bool omitTermFreqAndPositions)
71  {
72  if (this.isIndexed != isIndexed)
73  {
74  this.isIndexed = true; // once indexed, always index
75  }
76  if (isIndexed)
77  {
78  // if updated field data is not for indexing, leave the updates out
79  if (this.storeTermVector != storeTermVector)
80  {
81  this.storeTermVector = true; // once vector, always vector
82  }
83  if (this.storePositionWithTermVector != storePositionWithTermVector)
84  {
85  this.storePositionWithTermVector = true; // once vector, always vector
86  }
87  if (this.storeOffsetWithTermVector != storeOffsetWithTermVector)
88  {
89  this.storeOffsetWithTermVector = true; // once vector, always vector
90  }
91  if (this.storePayloads != storePayloads)
92  {
93  this.storePayloads = true;
94  }
95  if (this.omitNorms != omitNorms)
96  {
97  this.omitNorms = false; // once norms are stored, always store
98  }
99  if (this.omitTermFreqAndPositions != omitTermFreqAndPositions)
100  {
101  this.omitTermFreqAndPositions = true; // if one require omitTermFreqAndPositions at least once, it remains off for life
102  }
103  }
104  }
105 
106  public bool storePayloads_ForNUnit
107  {
108  get { return storePayloads; }
109  }
110 
111  public System.String name_ForNUnit
112  {
113  get { return name; }
114  }
115 
116  public bool isIndexed_ForNUnit
117  {
118  get { return isIndexed; }
119  }
120 
121  public bool omitNorms_ForNUnit
122  {
123  get { return omitNorms; }
124  }
125 
126  public bool omitTermFreqAndPositions_ForNUnit
127  {
128  get { return omitTermFreqAndPositions; }
129  }
130 
131  public bool storeTermVector_ForNUnit
132  {
133  get { return storeTermVector; }
134  }
135  }
136 }