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 java.util.Locale;
22
import org.apache.lucene.messages.Message;
23
import org.apache.lucene.messages.MessageImpl;
24
import org.apache.lucene.messages.NLS;
25
import org.apache.lucene.messages.NLSException;
26
import org.apache.lucene.queryParser.core.messages.QueryParserMessages;
27
import org.apache.lucene.queryParser.core.nodes.QueryNode;
31
* This exception should be thrown if something wrong happens when dealing with
35
* It also supports NLS messages.
43
public class QueryNodeException extends Exception implements NLSException {
45
private static final long serialVersionUID = -5962648855261624214L;
47
protected Message message = new MessageImpl(QueryParserMessages.EMPTY_MESSAGE);
49
public QueryNodeException(Message message) {
50
super(message.getKey());
52
this.message = message;
56
public QueryNodeException(Throwable throwable) {
60
public QueryNodeException(Message message, Throwable throwable) {
61
super(message.getKey(), throwable);
63
this.message = message;
67
public Message getMessageObject() {
72
public String getMessage() {
73
return getLocalizedMessage();
77
public String getLocalizedMessage() {
78
return getLocalizedMessage(Locale.getDefault());
81
public String getLocalizedMessage(Locale locale) {
82
return this.message.getLocalizedMessage(locale);
86
public String toString() {
87
return this.message.getKey() + ": " + getLocalizedMessage();