1 package org.apache.lucene.queryParser.ext;
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 import org.apache.lucene.queryParser.ParseException;
21 import org.apache.lucene.queryParser.QueryParser;
22 import org.apache.lucene.search.Query;
25 * This class represents an extension base class to the Lucene standard
26 * {@link QueryParser}. The {@link QueryParser} is generated by the JavaCC
27 * parser generator. Changing or adding functionality or syntax in the standard
28 * query parser requires changes to the JavaCC source file. To enable extending
29 * the standard query parser without changing the JavaCC sources and re-generate
30 * the parser the {@link ParserExtension} can be customized and plugged into an
31 * instance of {@link ExtendableQueryParser}, a direct subclass of
32 * {@link QueryParser}.
35 * @see ExtendableQueryParser
37 public abstract class ParserExtension {
40 * Processes the given {@link ExtensionQuery} and returns a corresponding
41 * {@link Query} instance. Subclasses must either return a {@link Query}
42 * instance or raise a {@link ParseException}. This method must not return
47 * @return a new query instance
48 * @throws ParseException
49 * if the query can not be parsed.
51 public abstract Query parse(final ExtensionQuery query) throws ParseException;