1 package org.apache.lucene.queryParser.spans;
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 java.util.List;
22 import org.apache.lucene.messages.MessageImpl;
23 import org.apache.lucene.queryParser.core.QueryNodeException;
24 import org.apache.lucene.queryParser.core.messages.QueryParserMessages;
25 import org.apache.lucene.queryParser.core.nodes.AndQueryNode;
26 import org.apache.lucene.queryParser.core.nodes.BooleanQueryNode;
27 import org.apache.lucene.queryParser.core.nodes.FieldQueryNode;
28 import org.apache.lucene.queryParser.core.nodes.OrQueryNode;
29 import org.apache.lucene.queryParser.core.nodes.QueryNode;
30 import org.apache.lucene.queryParser.core.processors.QueryNodeProcessorImpl;
33 * Validates every query node in a query node tree. This processor will pass
34 * fine if the query nodes are only {@link BooleanQueryNode}s,
35 * {@link OrQueryNode}s or {@link FieldQueryNode}s, otherwise an exception will
39 * If they are {@link AndQueryNode} or an instance of anything else that
40 * implements {@link FieldQueryNode} the exception will also be thrown.
42 public class SpansValidatorQueryNodeProcessor extends QueryNodeProcessorImpl {
45 protected QueryNode postProcessNode(QueryNode node) throws QueryNodeException {
52 protected QueryNode preProcessNode(QueryNode node) throws QueryNodeException {
54 if (!((node instanceof BooleanQueryNode && !(node instanceof AndQueryNode)) || node
55 .getClass() == FieldQueryNode.class)) {
56 throw new QueryNodeException(new MessageImpl(
57 QueryParserMessages.NODE_ACTION_NOT_SUPPORTED));
65 protected List<QueryNode> setChildrenOrder(List<QueryNode> children)
66 throws QueryNodeException {