001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: * $Header:$
018: */
019: package org.apache.beehive.netui.script;
020:
021: /**
022: * An exception thrown when errors occur evaluating an expression.
023: */
024: public class ExpressionEvaluationException extends Exception {
025:
026: private String _expression = null;
027: private String[] _contexts = null;
028: private String _localizedMessage = null;
029:
030: /**
031: * Construct an ExpressionEvaluationException.
032: */
033: public ExpressionEvaluationException() {
034: super ();
035: }
036:
037: /**
038: * Construct an ExpressionEvaluationException with the given message and
039: * the failed expression.
040: *
041: * @param message a String containing the text of the exception message
042: * @param expression the expression whose evaluation failed
043: */
044: public ExpressionEvaluationException(String message,
045: String expression) {
046: super (message);
047: this ._expression = expression;
048: }
049:
050: /**
051: * Construct an ExpressionEvaluationException with the given message,
052: * the failed expression, and cause.
053: *
054: * @param message a String containing the text of the exception message
055: * @param expression the expression whose evaluation failed
056: * @param cause a <code>Throwable</code> that is wrapped by this exception
057: */
058: public ExpressionEvaluationException(String message,
059: String expression, Throwable cause) {
060: super (message, cause);
061: this ._expression = expression;
062: }
063:
064: /**
065: * Construct a ExpressionEvaluationException with the given <code>message</code> and <code>cause</code>.
066: *
067: * @param expression a String containing the text of the exception message
068: * @param cause a <code>Throwable</code> that is wrapped by this exception
069: */
070: public ExpressionEvaluationException(String expression,
071: Throwable cause) {
072: super (cause);
073: this ._expression = expression;
074: }
075:
076: /**
077: * Get the expression whose failed evaluation cause this exception to be thrown.
078: *
079: * @return the expression that caused the problem
080: */
081: public String getExpression() {
082: return _expression;
083: }
084:
085: /**
086: * Set the set of top-level contexts that were available at the time
087: * that the expression failed.
088: *
089: * @param contexts the list of available contexts.
090: */
091: public void setAvailableContexts(String[] contexts) {
092: this ._contexts = contexts;
093: }
094:
095: /**
096: * Get the top-level contexts that were available at the time that the
097: * expression failed.
098: *
099: * @return the contexts that were available at the time the expression was evaluated or <code>null</code>
100: * if the contexts were not set.
101: */
102: public String[] getAvailableContexts() {
103: return _contexts;
104: }
105:
106: public void setLocalizedMessage(String localizedMessage) {
107: this ._localizedMessage = localizedMessage;
108: }
109:
110: public String getLocalizedMessage() {
111: return _localizedMessage;
112: }
113: }
|