View Javadoc

1   /*
2    * Copyright 2004-2006 the Seasar Foundation and the Others.
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, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.tuigwaa.system;
17  
18  import org.seasar.framework.message.MessageFormatter;
19  
20  public class TgwRuntimeException extends RuntimeException {
21  
22  	private static final long serialVersionUID = 2286971699966326123L;
23  
24  	private String messageCode;
25  
26  	private Object[] args;
27  
28  	private String message;
29  
30  	private String simpleMessage;
31  
32  	public TgwRuntimeException(String messageCode) {
33  		this(messageCode, null, null);
34  	}
35  
36  	public TgwRuntimeException(Throwable t) {
37  		this("ETGW4001", null, t);
38  		t.printStackTrace();
39  	}
40  
41  	public TgwRuntimeException(String messageCode, Object[] args) {
42  		this(messageCode, args, null);
43  	}
44  
45  	public TgwRuntimeException(String messageCode, Object[] args,
46  			Throwable cause) {
47  		super(cause);
48  		this.messageCode = messageCode;
49  		this.args = args;
50  		simpleMessage = MessageFormatter.getSimpleMessage(messageCode, args);
51  		message = "[" + messageCode + "]" + simpleMessage;
52  	}
53  
54  	public final String getMessageCode() {
55  		return messageCode;
56  	}
57  
58  	public final Object[] getArgs() {
59  		return args;
60  	}
61  
62  	public final String getMessage() {
63  		return message;
64  	}
65  
66  	protected void setMessage(String message) {
67  		this.message = message;
68  	}
69  
70  	public final String getSimpleMessage() {
71  		return simpleMessage;
72  	}
73  
74  }