Lucene.Net  3.0.3
Lucene.Net is a .NET port of the Java Lucene Indexing Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties
FieldScoreQuery.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.Search.Function
21 {
22 
62  [Serializable]
64  {
65 
77  public class Type
78  {
79 
81  public static readonly Type BYTE = new Type("byte");
82 
84  public static readonly Type SHORT = new Type("short");
85 
87  public static readonly Type INT = new Type("int");
88 
90  public static readonly Type FLOAT = new Type("float");
91 
92  private System.String typeName;
93  internal Type(System.String name)
94  {
95  this.typeName = name;
96  }
97  /*(non-Javadoc) <see cref="java.lang.Object.toString() */
98  public override System.String ToString()
99  {
100  return GetType().FullName + "::" + typeName;
101  }
102  }
103 
113  public FieldScoreQuery(System.String field, Type type):base(GetValueSource(field, type))
114  {
115  }
116 
117  // create the appropriate (cached) field value source.
118  private static ValueSource GetValueSource(System.String field, Type type)
119  {
120  if (type == Type.BYTE)
121  {
122  return new ByteFieldSource(field);
123  }
124  if (type == Type.SHORT)
125  {
126  return new ShortFieldSource(field);
127  }
128  if (type == Type.INT)
129  {
130  return new IntFieldSource(field);
131  }
132  if (type == Type.FLOAT)
133  {
134  return new FloatFieldSource(field);
135  }
136  throw new System.ArgumentException(type + " is not a known Field Score Query Type!");
137  }
138  }
139 }