Add --enable-deletion option to buildindex. If used, buildindex will remove deleted...
[beagle.git] / beagled / Lucene.Net / Util / Parameter.cs
blob0dfb0d639157081ec34d50f30a2bfffb624fd1f8
1 /*
2 * Copyright 2005 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 using System;
17 namespace Lucene.Net.Util
20 /// <summary> A serializable Enum class.</summary>
21 [Serializable]
22 public abstract class Parameter
24 internal static System.Collections.IDictionary allParameters = new System.Collections.Hashtable();
26 private System.String name;
28 private Parameter()
30 // typesafe enum pattern, no public constructor
33 protected internal Parameter(System.String name)
35 // typesafe enum pattern, no public constructor
36 this.name = name;
37 System.String key = MakeKey(name);
39 if (allParameters.Contains(key))
40 throw new System.ArgumentException("Parameter name " + key + " already used!");
42 allParameters[key] = this;
45 private System.String MakeKey(System.String name)
47 return GetType() + " " + name;
50 public override System.String ToString()
52 return name;
55 /// <summary> Resolves the deserialized instance to the local reference for accurate
56 /// equals() and == comparisons.
57 ///
58 /// </summary>
59 /// <returns> a reference to Parameter as resolved in the local VM
60 /// </returns>
61 /// <throws> ObjectStreamException </throws>
62 protected internal virtual System.Object ReadResolve()
64 System.Object par = allParameters[MakeKey(name)];
66 if (par == null)
67 throw new System.IO.IOException("Unknown parameter value: " + name);
69 return par;