1 package org.apache.lucene.xmlparser.builders;
3 import org.apache.lucene.search.spans.SpanFirstQuery;
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;
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
16 * http://www.apache.org/licenses/LICENSE-2.0
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.
28 public class SpanFirstBuilder extends SpanBuilderBase
30 SpanQueryBuilder factory;
32 public SpanFirstBuilder(SpanQueryBuilder factory)
35 this.factory = factory;
38 public SpanQuery getSpanQuery(Element e) throws ParserException
40 int end=DOMUtils.getAttribute(e,"end",1);
41 Element child=DOMUtils.getFirstChildElement(e);
42 SpanQuery q=factory.getSpanQuery(child);
44 SpanFirstQuery sfq = new SpanFirstQuery(q,end);
46 sfq.setBoost(DOMUtils.getAttribute(e,"boost",1.0f));