View Javadoc

1   /*
2    * Copyright 2003,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   * This source code implements specifications defined by the Java
18   * Community Process. In order to remain compliant with the specification
19   * DO NOT add / change / or delete method signatures!
20   */
21  package javax.portlet;
22  
23  /***
24   * The <CODE>PortletModeException</CODE> is thrown when a portlet
25   * tries to use or set a portlet mode that is not supported by the current
26   * runtime environment or the portlet.
27   */
28  
29  public class PortletModeException extends PortletException
30  {
31  
32  
33    private transient PortletMode _mode = null;
34  
35    /***
36     * Constructs a new portlet mode exception with the given text and the
37     * portlet mode that caused this exception. The
38     * portlet container may use the text and portlet mode write it to a log.
39     *
40     * @param   text
41     *          the exception text
42     * @param   mode
43     *          the mode causing the exception
44     */
45  
46    public PortletModeException (String text, PortletMode mode)
47    {
48      super (text);
49      _mode = mode;
50    }
51  
52    /***
53     * Constructs a new portlet mode exception when the portlet needs to do
54     * the following:
55     * <ul>
56     * <il>throw an exception 
57     * <li>include a message about the "root cause" that interfered
58     *     with its normal operation
59     * <li>include a description message
60     * <li>include the portlet mode that caused this exception
61     * </ul>
62     *
63     * @param   text
64     *          the exception text
65     * @param   cause
66     *          the root cause
67     * @param   mode
68     *          the mode causing the exception
69     */
70    
71    public PortletModeException (String text, Throwable cause, PortletMode mode)
72    {
73      super(text, cause);
74      _mode = mode;
75    }
76  
77    /***
78     * Constructs a new portlet mode exception when the portlet needs to throw an
79     * exception. The exception message is based on the localized message
80     * of the underlying exception and the portlet mode that caused this exception.
81     *
82     * @param   cause
83     *          the root cause
84     * @param   mode
85     *          the mode causing the exception
86     */
87  
88    public PortletModeException (Throwable cause, PortletMode mode)
89    {
90      super(cause);
91      _mode = mode;
92    }
93  
94    /***
95     * Returns the unsupported portlet mode causing this exception.
96     * 
97     * @return  the portlet mode that caused this exception
98     */
99  
100   public PortletMode getMode()
101   {
102     return _mode;
103   }
104 }