2
* Created on 25-Jan-2006
4
package org.apache.lucene.xmlparser.builders;
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;
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
25
* http://www.apache.org/licenses/LICENSE-2.0
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.
36
public class BooleanFilterBuilder implements FilterBuilder {
38
private FilterBuilder factory;
40
public BooleanFilterBuilder(FilterBuilder factory)
45
public Filter getFilter(Element e) throws ParserException {
46
BooleanFilter bf=new BooleanFilter();
47
NodeList nl = e.getChildNodes();
49
for(int i=0;i<nl.getLength();i++)
51
Node node = nl.item(i);
52
if(node.getNodeName().equals("Clause"))
54
Element clauseElem=(Element) node;
55
BooleanClause.Occur occurs=BooleanQueryBuilder.getOccursValue(clauseElem);
57
Element clauseFilter=DOMUtils.getFirstChildOrFail(clauseElem);
58
Filter f=factory.getFilter(clauseFilter);
59
bf.add(new FilterClause(f,occurs));