KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > bcel > verifier > exc > AssertionViolatedException


1 /*
2  * Copyright 2000-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  */

17 package org.apache.bcel.verifier.exc;
18
19
20 /**
21  * Instances of this class should never be thrown. When such an instance is thrown,
22  * this is due to an INTERNAL ERROR of BCEL's class file verifier "JustIce".
23  *
24  * @version $Id: AssertionViolatedException.java 386056 2006-03-15 11:31:56Z tcurdt $
25  * @author Enver Haase
26  */

27 public final class AssertionViolatedException extends RuntimeException JavaDoc{
28     /** The error message. */
29     private String JavaDoc detailMessage;
30     /** Constructs a new AssertionViolatedException with null as its error message string. */
31     public AssertionViolatedException(){
32         super();
33     }
34     /**
35      * Constructs a new AssertionViolatedException with the specified error message preceded
36      * by "INTERNAL ERROR: ".
37      */

38     public AssertionViolatedException(String JavaDoc message){
39         super(message = "INTERNAL ERROR: "+message); // Thanks to Java, the constructor call here must be first.
40
detailMessage=message;
41     }
42     /** Extends the error message with a string before ("pre") and after ("post") the
43         'old' error message. All of these three strings are allowed to be null, and null
44         is always replaced by the empty string (""). In particular, after invoking this
45         method, the error message of this object can no longer be null.
46     */

47     public void extendMessage(String JavaDoc pre, String JavaDoc post){
48         if (pre == null) {
49             pre="";
50         }
51         if (detailMessage == null) {
52             detailMessage="";
53         }
54         if (post == null) {
55             post="";
56         }
57         detailMessage = pre+detailMessage+post;
58     }
59     /**
60      * Returns the error message string of this AssertionViolatedException object.
61      * @return the error message string of this AssertionViolatedException.
62      */

63     public String JavaDoc getMessage(){
64         return detailMessage;
65     }
66
67     /**
68      * DO NOT USE. It's for experimental testing during development only.
69      */

70     public static void main(String JavaDoc[] args){
71         AssertionViolatedException ave = new AssertionViolatedException("Oops!");
72         ave.extendMessage("\nFOUND:\n\t","\nExiting!!\n");
73         throw ave;
74     }
75
76 }
77
Popular Tags