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