Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/media/mn8/event/mn8Exception.java


1   /* 
2    * $COPYRIGHT$
3    * $Id: mn8Exception.java,v 1.1 2001/08/06 08:42:06 neuro Exp $
4    *
5    * Date        Author            Changes 
6    * Apr 22 2001 Remus Pereni      Created
7    */
8   package org.media.mn8.event;
9   
10  import org.media.mn8.MessageFormatter;
11  import java.io.PrintStream;
12  import java.io.PrintWriter;
13  /** 
14   * <p>The basic mn8 exception class.
15   * <p>In mn8 all signaling of user messages is done through
16   * exceptions. All mn8 exceptions are derived from this
17   * class, and having separate exception types for different
18   * kind of exceptions (general system errors and warnings, 
19   * mn8 interpretation specific errors). In this way a user can
20   * choose the amount of information wanted, and use it's custom
21   * message handling utilities. Ex: general errors go on screen, mn8
22   * warning go to email.
23   * For normal interpretation, all exceptions are caught by the
24   * LogManager and displayed on the system console.
25   * @author <a href="mailto:remus@nolimits.ro">Remus Pereni</a>
26   * @version $Revision: 1.1 $ $Date: 2001/08/06 08:42:06 $
27   * @see org.media.mn8.LogManager
28   */
29  
30  public class mn8Exception extends RuntimeException {
31      private String _messageTypeId = null;
32      private String _messageId = null; 
33      private String _optionalInfo = null;
34      private String _suplementaryInfo = null;
35  
36      private Exception _generatorException = null;
37  
38      public mn8Exception( String message ) {
39          super( message );
40      }
41  
42      
43      public mn8Exception( String type_id, String message_id ) {
44          _messageTypeId = type_id;
45          _messageId = message_id;
46      }
47  
48  
49      public mn8Exception( String type_id, String message_id, 
50                           String optional, String suplement ) {
51          _messageTypeId = type_id;
52          _messageId = message_id;
53          _optionalInfo = optional;
54          _suplementaryInfo = suplement;
55      }
56  
57  
58      public mn8Exception( String type_id, String message_id, 
59                           String optional ) {
60          _messageTypeId = type_id;
61          _messageId = message_id;
62          _optionalInfo = optional;
63      }
64  
65  
66      public void setGeneratorException( Exception initialException ) {
67          _generatorException = initialException;
68      }
69  
70  
71      public Exception getGeneratorException() {
72          return _generatorException;
73      }
74  
75  
76      public String getMessage() {
77          if ( _generatorException != null )
78              return _generatorException.getMessage();
79          else 
80              return "";            
81      }
82  
83  
84      public void setMessageTypeId ( String messageTypeId ) {
85          _messageTypeId  = messageTypeId;
86      }
87  
88  
89      public String getMessageTypeId() {
90          return _messageTypeId;
91      }
92  
93  
94      public void setMessageId ( String messageId ) {
95          _messageId = messageId;
96      }
97  
98      
99      public String getMessageId() { 
100         return _messageId;
101     }
102 
103 
104     public void setOptionalInfo( String optionalInfo ) {
105         _optionalInfo = optionalInfo;
106     }
107 
108 
109     public String getOptionalInfo() {
110         return _optionalInfo;
111     }
112 
113     
114     public void setSuplementaryInfo( String suplemantaryInfo ){
115         _suplementaryInfo =suplemantaryInfo;
116     }
117 
118     public String getSuplementaryInfo(){
119         return _suplementaryInfo;
120     }
121 
122 
123     public String toString() {
124         return MessageFormatter.getReference().getMessage( _messageTypeId,
125                                                            _messageId,
126                                                            _optionalInfo,
127                                                            _suplementaryInfo );
128     }
129     
130     
131     public void printStackTrace( PrintStream s) {
132         if ( _generatorException != null ) 
133             _generatorException.printStackTrace( s );
134     }
135 
136 
137     public void printStackTrace( PrintWriter w) {
138         if ( _generatorException != null ) 
139             _generatorException.printStackTrace( w );
140     }
141 
142 
143     public void printStackTrace() {
144         if ( _generatorException != null ) 
145             _generatorException.printStackTrace();
146     }
147 
148 
149 }