Coverage details for org.chwf.taglib.base.TagException

LineHitsSource
1 /*
2 Chrysalis Web Framework [http://chrysalis.sourceforge.net]
3 Copyright (c) 2002, 2003, 2004, Paul Strack
4  
5 All rights reserved.
6  
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9  
10 1. Redistributions of source code must retain the above copyright notice, this
11 list of conditions and the following disclaimer.
12  
13 2. Redistributions in binary form must reproduce the above copyright notice,
14 this list of conditions and the following disclaimer in the documentation
15 and/or other materials provided with the distribution.
16  
17 3. Neither the name of the copyright holder nor the names of its contributors
18 may be used to endorse or promote products derived from this software without
19 specific prior written permission.
20  
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
25 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32  
33 package org.chwf.taglib.base;
34  
35 import javax.servlet.jsp.JspTagException;
36  
37 import org.chwf.i18n.Message;
38  
39 /**
40  * Exception for Chrysalis tag library exceptions.
41  *
42  * @author <a href="mailto:pfstrack@users.sourceforge.net">Paul Strack</a>
43  */
441public class TagException extends JspTagException {
45  
46   /** Message key. */
47   static final String MESSAGE_OBJECT_NOT_FOUND = "OBJECT_NOT_FOUND";
48  
49   /** Message key. */
50   static final String MESSAGE_OBJECT_NOT_DEFINED = "OBJECT_NOT_DEFINED";
51  
52   /** Message key. */
53   static final String MESSAGE_OBJECT_UNEXPECTED_TYPE = "OBJECT_UNEXPECTED_TYPE";
54  
55   /** Message key. */
56   static final String MESSAGE_PROPERTY_UNEXPECTED_TYPE =
57     "PROPERTY_UNEXPECTED_TYPE";
58  
59   /** Empty array. */
601  private static final Object[] EMPTY_ARRAY = new Object[0];
61  
62   /** Root cause. */
63   private final Throwable rootCause;
64  
65   /**
66    * Constructor.
67    *
68    * @param pattern Key or pattern.
69    */
70   public TagException(String pattern) {
714    super(deriveMessage(pattern, EMPTY_ARRAY));
724    this.rootCause = null;
734  }
74  
75   /**
76    * Constructor.
77    *
78    * @param pattern Key or pattern.
79    * @param arguments Arguments.
80    */
81   public TagException(String pattern, Object[] arguments) {
826    super(deriveMessage(pattern, arguments));
836    this.rootCause = null;
846  }
85  
86   /**
87    * Constructor.
88    *
89    * @param rootCause Nested error.
90    */
91   public TagException(Throwable rootCause) {
928    super(rootCause.getMessage());
938    this.rootCause = rootCause;
948  }
95  
96   /**
97    * Root cause.
98    *
99    * @return Root cause.
100    */
101   public Throwable getRootCause() {
1020    return this.rootCause;
103   }
104  
105   /**
106    * Derive message.
107    *
108    * @param pattern Key or pattern.
109    * @param arguments Arguments.
110    * @return The message as a string.
111    */
112   private static String deriveMessage(String pattern, Object[] arguments) {
11310    return Message
114       .getMessage(pattern, arguments, TagException.class)
115       .toString();
116   }
117 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.