pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / contrib / xml-query-parser / src / java / org / apache / lucene / xmlparser / builders / RangeFilterBuilder.java
1 /*
2  * Created on 25-Jan-2006
3  */
4 package org.apache.lucene.xmlparser.builders;
5
6 import org.apache.lucene.search.Filter;
7 import org.apache.lucene.search.TermRangeFilter;
8 import org.apache.lucene.xmlparser.DOMUtils;
9 import org.apache.lucene.xmlparser.FilterBuilder;
10 import org.apache.lucene.xmlparser.ParserException;
11 import org.w3c.dom.Element;
12 /**
13  * Licensed to the Apache Software Foundation (ASF) under one or more
14  * contributor license agreements.  See the NOTICE file distributed with
15  * this work for additional information regarding copyright ownership.
16  * The ASF licenses this file to You under the Apache License, Version 2.0
17  * (the "License"); you may not use this file except in compliance with
18  * the License.  You may obtain a copy of the License at
19  *
20  *     http://www.apache.org/licenses/LICENSE-2.0
21  *
22  * Unless required by applicable law or agreed to in writing, software
23  * distributed under the License is distributed on an "AS IS" BASIS,
24  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25  * See the License for the specific language governing permissions and
26  * limitations under the License.
27  */
28
29
30 /**
31  * 
32  */
33 public class RangeFilterBuilder implements FilterBuilder {
34
35
36         public Filter getFilter(Element e) throws ParserException {
37                 
38                 String fieldName=DOMUtils.getAttributeWithInheritance(e,"fieldName");
39                 
40                 String lowerTerm=e.getAttribute("lowerTerm");
41                 String upperTerm=e.getAttribute("upperTerm");
42                 boolean includeLower=DOMUtils.getAttribute(e,"includeLower",true);
43                 boolean includeUpper=DOMUtils.getAttribute(e,"includeUpper",true);
44                 return new TermRangeFilter(fieldName,lowerTerm,upperTerm,includeLower,includeUpper);
45         }
46
47 }