KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > beehive > netui > script > ExpressionEvaluationException


1 /*
2  * Copyright 2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * $Header:$
17  */

18 package org.apache.beehive.netui.script;
19
20 // java imports
21

22 // internal imports
23

24 // external imports
25

26 /**
27  * The most general exception thrown when an error occurs in evaluating
28  * an expression.
29  */

30 public class ExpressionEvaluationException
31     extends Exception JavaDoc {
32
33     private String JavaDoc expression = null;
34     private String JavaDoc[] contexts = null;
35     private String JavaDoc localizedMessage = null;
36
37     /**
38      * Construct an ExpressionEvaluationException.
39      */

40     public ExpressionEvaluationException() {
41         super();
42     }
43
44     /**
45      * Construct an ExpressionEvaluationException with the given message and
46      * the failed expression.
47      *
48      * @param message a String containing the text of the exception message
49      * @param expression the expression whose evaluation failed
50      */

51     public ExpressionEvaluationException(String JavaDoc message, String JavaDoc expression) {
52         super(message);
53         this.expression = expression;
54     }
55
56     /**
57      * Construct an ExpressionEvaluationException with the given message,
58      * the failed expression, and cause.
59      *
60      * @param message a String containing the text of the exception message
61      * @param expression the expression whose evaluation failed
62      * @param cause a <code>Throwable</code> that is wrapped by this exception
63      */

64     public ExpressionEvaluationException(String JavaDoc message, String JavaDoc expression, Throwable JavaDoc cause) {
65         super(message, cause);
66         this.expression = expression;
67     }
68
69     /**
70      * Construct a ExpressionEvaluationException with the given <code>message</code> and <code>cause</code>.
71      *
72      * @param expression a String containing the text of the exception message
73      * @param cause a <code>Throwable</code> that is wrapped by this exception
74      */

75     public ExpressionEvaluationException(String JavaDoc expression, Throwable JavaDoc cause) {
76         super(cause);
77         this.expression = expression;
78     }
79
80     /**
81      * Get the expression whose failed evaluation cause this exception to be thrown.
82      *
83      * @return the expression that caused the problem
84      */

85     public String JavaDoc getExpression() {
86         return expression;
87     }
88
89     /**
90      * Set the set of top-level contexts that were available at the time
91      * that the expression failed.
92      *
93      * @param contexts the list of available contexts.
94      */

95     public void setAvailableContexts(String JavaDoc[] contexts) {
96         this.contexts = contexts;
97     }
98
99     /**
100      * Get the top-level contexts that were available at the time that the
101      * expression failed.
102      *
103      * @return the contexts that were available at the time the expression was evaluated or <code>null</code>
104      * if the contexts were not set.
105      */

106     public String JavaDoc[] getAvailableContexts() {
107         return contexts;
108     }
109
110     public void setLocalizedMessage(String JavaDoc localizedMessage) {
111         this.localizedMessage = localizedMessage;
112     }
113
114     public String JavaDoc getLocalizedMessage() {
115         return localizedMessage;
116     }
117 }
118
Popular Tags