1 package org.apache.lucene.xmlparser.builders;
3 import java.util.HashMap;
5 import org.apache.lucene.search.Query;
6 import org.apache.lucene.search.spans.SpanQuery;
7 import org.apache.lucene.xmlparser.ParserException;
8 import org.w3c.dom.Element;
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
17 * http://www.apache.org/licenses/LICENSE-2.0
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.
29 public class SpanQueryBuilderFactory implements SpanQueryBuilder {
31 HashMap<String,SpanQueryBuilder> builders=new HashMap<String,SpanQueryBuilder>();
33 public Query getQuery(Element e) throws ParserException {
34 return getSpanQuery(e);
36 public void addBuilder(String nodeName,SpanQueryBuilder builder)
38 builders.put(nodeName,builder);
40 public SpanQuery getSpanQuery(Element e) throws ParserException
42 SpanQueryBuilder builder= builders.get(e.getNodeName());
45 throw new ParserException("No SpanQueryObjectBuilder defined for node "+e.getNodeName());
47 return builder.getSpanQuery(e);