Merge pull request #409 from Alkarex/patch-1
[mono.git] / mcs / tools / monkeydoc / Lucene.Net / Lucene.Net / Search / TermRangeFilter.cs
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 Mono.Lucene.Net.Search
21 {
22         
23         /// <summary> A Filter that restricts search results to a range of values in a given
24         /// field.
25         /// 
26         /// <p/>This filter matches the documents looking for terms that fall into the
27         /// supplied range according to {@link String#compareTo(String)}. It is not intended
28         /// for numerical ranges, use {@link NumericRangeFilter} instead.
29         /// 
30         /// <p/>If you construct a large number of range filters with different ranges but on the 
31         /// same field, {@link FieldCacheRangeFilter} may have significantly better performance. 
32         /// </summary>
33         /// <since> 2.9
34         /// </since>
35         [Serializable]
36         public class TermRangeFilter:MultiTermQueryWrapperFilter
37         {
38                 
39                 /// <param name="fieldName">The field this range applies to
40                 /// </param>
41                 /// <param name="lowerTerm">The lower bound on this range
42                 /// </param>
43                 /// <param name="upperTerm">The upper bound on this range
44                 /// </param>
45                 /// <param name="includeLower">Does this range include the lower bound?
46                 /// </param>
47                 /// <param name="includeUpper">Does this range include the upper bound?
48                 /// </param>
49                 /// <throws>  IllegalArgumentException if both terms are null or if </throws>
50                 /// <summary>  lowerTerm is null and includeLower is true (similar for upperTerm
51                 /// and includeUpper)
52                 /// </summary>
53                 public TermRangeFilter(System.String fieldName, System.String lowerTerm, System.String upperTerm, bool includeLower, bool includeUpper):base(new TermRangeQuery(fieldName, lowerTerm, upperTerm, includeLower, includeUpper))
54                 {
55                 }
56                 
57                 /// <summary> <strong>WARNING:</strong> Using this constructor and supplying a non-null
58                 /// value in the <code>collator</code> parameter will cause every single 
59                 /// index Term in the Field referenced by lowerTerm and/or upperTerm to be
60                 /// examined.  Depending on the number of index Terms in this Field, the 
61                 /// operation could be very slow.
62                 /// 
63                 /// </summary>
64                 /// <param name="lowerTerm">The lower bound on this range
65                 /// </param>
66                 /// <param name="upperTerm">The upper bound on this range
67                 /// </param>
68                 /// <param name="includeLower">Does this range include the lower bound?
69                 /// </param>
70                 /// <param name="includeUpper">Does this range include the upper bound?
71                 /// </param>
72                 /// <param name="collator">The collator to use when determining range inclusion; set
73                 /// to null to use Unicode code point ordering instead of collation.
74                 /// </param>
75                 /// <throws>  IllegalArgumentException if both terms are null or if </throws>
76                 /// <summary>  lowerTerm is null and includeLower is true (similar for upperTerm
77                 /// and includeUpper)
78                 /// </summary>
79                 public TermRangeFilter(System.String fieldName, System.String lowerTerm, System.String upperTerm, bool includeLower, bool includeUpper, System.Globalization.CompareInfo collator):base(new TermRangeQuery(fieldName, lowerTerm, upperTerm, includeLower, includeUpper, collator))
80                 {
81                 }
82                 
83                 /// <summary> Constructs a filter for field <code>fieldName</code> matching
84                 /// less than or equal to <code>upperTerm</code>.
85                 /// </summary>
86                 public static TermRangeFilter Less(System.String fieldName, System.String upperTerm)
87                 {
88                         return new TermRangeFilter(fieldName, null, upperTerm, false, true);
89                 }
90                 
91                 /// <summary> Constructs a filter for field <code>fieldName</code> matching
92                 /// greater than or equal to <code>lowerTerm</code>.
93                 /// </summary>
94                 public static TermRangeFilter More(System.String fieldName, System.String lowerTerm)
95                 {
96                         return new TermRangeFilter(fieldName, lowerTerm, null, true, false);
97                 }
98                 
99                 /// <summary>Returns the field name for this filter </summary>
100                 public virtual System.String GetField()
101                 {
102                         return ((TermRangeQuery) query).GetField();
103                 }
104                 
105                 /// <summary>Returns the lower value of this range filter </summary>
106                 public virtual System.String GetLowerTerm()
107                 {
108                         return ((TermRangeQuery) query).GetLowerTerm();
109                 }
110                 
111                 /// <summary>Returns the upper value of this range filter </summary>
112                 public virtual System.String GetUpperTerm()
113                 {
114                         return ((TermRangeQuery) query).GetUpperTerm();
115                 }
116                 
117                 /// <summary>Returns <code>true</code> if the lower endpoint is inclusive </summary>
118                 public virtual bool IncludesLower()
119                 {
120                         return ((TermRangeQuery) query).IncludesLower();
121                 }
122                 
123                 /// <summary>Returns <code>true</code> if the upper endpoint is inclusive </summary>
124                 public virtual bool IncludesUpper()
125                 {
126                         return ((TermRangeQuery) query).IncludesUpper();
127                 }
128                 
129                 /// <summary>Returns the collator used to determine range inclusion, if any. </summary>
130                 public virtual System.Globalization.CompareInfo GetCollator()
131                 {
132                         return ((TermRangeQuery) query).GetCollator();
133                 }
134         }
135 }