~ubuntu-branches/ubuntu/trusty/pylucene/trusty

« back to all changes in this revision

Viewing changes to lucene-java-2.3.1/contrib/xml-query-parser/src/java/org/apache/lucene/xmlparser/builders/BooleanFilterBuilder.java

  • Committer: Package Import Robot
  • Author(s): Dmitry Nezhevenko
  • Date: 2012-04-23 16:43:55 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120423164355-grqtepnwtecdjfk2
Tags: 3.5.0-1
* New maintainer (closes: 670179)
* New upstream release
* Switch to dpkg-source 3.0 (quilt) format
* Switch to machine-readable debian/copyright
* Bump debian/compat to 8, drop debian/pycompat
* Switch from cdbs to dh
* Add watch file
* Build for all supported versions of python2 (closes: 581198, 632240)
* Rename binary package to python-lucene (closes: 581197)
* Add -dbg package

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Created on 25-Jan-2006
3
 
 */
4
 
package org.apache.lucene.xmlparser.builders;
5
 
 
6
 
import org.apache.lucene.search.BooleanClause;
7
 
import org.apache.lucene.search.BooleanFilter;
8
 
import org.apache.lucene.search.Filter;
9
 
import org.apache.lucene.search.FilterClause;
10
 
import org.apache.lucene.xmlparser.DOMUtils;
11
 
import org.apache.lucene.xmlparser.FilterBuilder;
12
 
import org.apache.lucene.xmlparser.ParserException;
13
 
import org.w3c.dom.Element;
14
 
import org.w3c.dom.Node;
15
 
import org.w3c.dom.NodeList;
16
 
 
17
 
/**
18
 
 * Licensed to the Apache Software Foundation (ASF) under one or more
19
 
 * contributor license agreements.  See the NOTICE file distributed with
20
 
 * this work for additional information regarding copyright ownership.
21
 
 * The ASF licenses this file to You under the Apache License, Version 2.0
22
 
 * (the "License"); you may not use this file except in compliance with
23
 
 * the License.  You may obtain a copy of the License at
24
 
 *
25
 
 *     http://www.apache.org/licenses/LICENSE-2.0
26
 
 *
27
 
 * Unless required by applicable law or agreed to in writing, software
28
 
 * distributed under the License is distributed on an "AS IS" BASIS,
29
 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30
 
 * See the License for the specific language governing permissions and
31
 
 * limitations under the License.
32
 
 */
33
 
/**
34
 
 * @author maharwood 
35
 
 */
36
 
public class BooleanFilterBuilder implements FilterBuilder {
37
 
        
38
 
        private FilterBuilder factory;
39
 
 
40
 
        public BooleanFilterBuilder(FilterBuilder factory)
41
 
        {
42
 
                this.factory=factory;
43
 
        }
44
 
 
45
 
        public Filter getFilter(Element e) throws ParserException {
46
 
                BooleanFilter bf=new BooleanFilter();
47
 
                NodeList nl = e.getChildNodes();
48
 
                
49
 
                for(int i=0;i<nl.getLength();i++)
50
 
                {
51
 
                        Node node = nl.item(i);
52
 
                        if(node.getNodeName().equals("Clause"))
53
 
                        {
54
 
                                Element clauseElem=(Element) node;
55
 
                                BooleanClause.Occur occurs=BooleanQueryBuilder.getOccursValue(clauseElem);
56
 
                        
57
 
                                Element clauseFilter=DOMUtils.getFirstChildOrFail(clauseElem);
58
 
                                Filter f=factory.getFilter(clauseFilter);
59
 
                                bf.add(new FilterClause(f,occurs));
60
 
                        }
61
 
                }
62
 
                
63
 
                return bf;
64
 
        }
65
 
 
66
 
}