1 package org.apache.lucene.queryParser.core;
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.messages.Message;
21 import org.apache.lucene.messages.MessageImpl;
22 import org.apache.lucene.queryParser.core.messages.QueryParserMessages;
23 import org.apache.lucene.queryParser.core.nodes.QueryNode;
24 import org.apache.lucene.queryParser.core.parser.SyntaxParser;
27 * This should be thrown when an exception happens during the query parsing from
28 * string to the query node tree.
30 * @see QueryNodeException
34 public class QueryNodeParseException extends QueryNodeException {
36 private static final long serialVersionUID = 8197535103538766773L;
38 private CharSequence query;
40 private int beginColumn = -1;
42 private int beginLine = -1;
44 private String errorToken = "";
46 public QueryNodeParseException(Message message) {
50 public QueryNodeParseException(Throwable throwable) {
54 public QueryNodeParseException(Message message, Throwable throwable) {
55 super(message, throwable);
58 public void setQuery(CharSequence query) {
60 this.message = new MessageImpl(
61 QueryParserMessages.INVALID_SYNTAX_CANNOT_PARSE, query, "");
64 public CharSequence getQuery() {
70 * the errorToken in the query
72 protected void setErrorToken(String errorToken) {
73 this.errorToken = errorToken;
76 public String getErrorToken() {
77 return this.errorToken;
80 public void setNonLocalizedMessage(Message message) {
81 this.message = message;
85 * For EndOfLine and EndOfFile ("<EOF>") parsing problems the last char in the
86 * string is returned For the case where the parser is not able to figure out
87 * the line and column number -1 will be returned
89 * @return line where the problem was found
91 public int getBeginLine() {
92 return this.beginLine;
96 * For EndOfLine and EndOfFile ("<EOF>") parsing problems the last char in the
97 * string is returned For the case where the parser is not able to figure out
98 * the line and column number -1 will be returned
100 * @return column of the first char where the problem was found
102 public int getBeginColumn() {
103 return this.beginColumn;
108 * the beginLine to set
110 protected void setBeginLine(int beginLine) {
111 this.beginLine = beginLine;
116 * the beginColumn to set
118 protected void setBeginColumn(int beginColumn) {
119 this.beginColumn = beginColumn;