pylucene 3.5.0-3
[pylucene.git] / lucene-java-3.5.0 / lucene / contrib / xml-query-parser / src / java / org / apache / lucene / xmlparser / builders / SpanNotBuilder.java
1 package org.apache.lucene.xmlparser.builders;
2
3 import org.apache.lucene.search.spans.SpanNotQuery;
4 import org.apache.lucene.search.spans.SpanQuery;
5 import org.apache.lucene.xmlparser.DOMUtils;
6 import org.apache.lucene.xmlparser.ParserException;
7 import org.w3c.dom.Element;
8 /**
9  * Licensed to the Apache Software Foundation (ASF) under one or more
10  * contributor license agreements.  See the NOTICE file distributed with
11  * this work for additional information regarding copyright ownership.
12  * The ASF licenses this file to You under the Apache License, Version 2.0
13  * (the "License"); you may not use this file except in compliance with
14  * the License.  You may obtain a copy of the License at
15  *
16  *     http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  */
24
25 /**
26  * 
27  */
28 public class SpanNotBuilder extends SpanBuilderBase
29 {
30     
31     SpanQueryBuilder factory;    
32
33     /**
34      * @param factory
35      */
36     public SpanNotBuilder(SpanQueryBuilder factory)
37     {
38         super();
39         this.factory = factory;
40     }
41         public SpanQuery getSpanQuery(Element e) throws ParserException
42         {
43             Element includeElem=DOMUtils.getChildByTagOrFail(e,"Include");
44         includeElem=DOMUtils.getFirstChildOrFail(includeElem);
45
46             Element excludeElem=DOMUtils.getChildByTagOrFail(e,"Exclude");
47         excludeElem=DOMUtils.getFirstChildOrFail(excludeElem);
48
49             SpanQuery include=factory.getSpanQuery(includeElem);
50             SpanQuery exclude=factory.getSpanQuery(excludeElem);
51             
52                 SpanNotQuery snq = new SpanNotQuery(include,exclude);
53                 
54                 snq.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));
55                 return snq;
56         }
57
58 }