View Javadoc
1 /* 2 * Scope: a generic MVC framework. 3 * Copyright (c) 2000-2002, The Scope team 4 * All rights reserved. 5 * 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 14 * Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * Neither the name "Scope" nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR 27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 * 35 * 36 * $Id: ControlException.java,v 1.4 2002/09/05 15:41:45 ludovicc Exp $ 37 */ 38 package org.scopemvc.core; 39 40 41 import org.scopemvc.util.LocalizedException; 42 import org.scopemvc.util.UIStrings; 43 44 /*** 45 * <P> 46 * 47 * {@link Controller}s throw ControlExceptions while responding to {@link 48 * Control}s if something goes wrong that must be reported to the user. A 49 * ControlException is a {@link org.scopemvc.util.LocalizedException}. </P> <P> 50 * 51 * ControlExceptions contain a Control ID that can be used by an error handler 52 * to identify the Control that caused the exception. For example, the Control 53 * ID could be used to get a String title from UIStrings for a Swing error 54 * dialog. The error handling implementation in BasicController automatically 55 * populates the Control ID. </P> 56 * 57 * @author <A HREF="mailto:smeyfroi@users.sourceforge.net">Steve Meyfroidt</A> 58 * @created 05 August 2002 59 * @version $Revision: 1.4 $ $Date: 2002/09/05 15:41:45 $ 60 */ 61 public final class ControlException extends LocalizedException { 62 63 private String sourceControlID; 64 65 66 /*** 67 * Constructor for the ControlException object 68 * 69 * @param inMessageID a message ID that identifies the localised 70 * user-readable message in {@link org.scopemvc.util.UIStrings 71 * UIStrings} 72 */ 73 public ControlException(String inMessageID) { 74 super(inMessageID); 75 } 76 77 78 /*** 79 * Constructor for the ControlException object 80 * 81 * @param inMessageID a message ID that identifies the localised 82 * user-readable message in {@link org.scopemvc.util.UIStrings 83 * UIStrings} 84 * @param inMessageParameter one parameter to be substituted in the message 85 * as {@link java.text.MessageFormat} 86 */ 87 public ControlException(String inMessageID, Object inMessageParameter) { 88 super(inMessageID, inMessageParameter); 89 } 90 91 92 /*** 93 * Constructor for the ControlException object 94 * 95 * @param inMessageID a message ID that identifies the localised 96 * user-readable message in {@link org.scopemvc.util.UIStrings 97 * UIStrings} 98 * @param inMessageParameters a set of parameters to be substituted in the 99 * message as {@link java.text.MessageFormat} 100 */ 101 public ControlException(String inMessageID, Object[] inMessageParameters) { 102 super(inMessageID, inMessageParameters); 103 } 104 105 106 /*** 107 * Use the source Control ID to get a localised name from the {@link 108 * org.scopemvc.util.UIStrings UIStrings}. 109 * 110 * @return Localized name of Control ID or empty String if no Control ID 111 * set. 112 */ 113 public final String getLocalizedSourceControlName() { 114 if (sourceControlID == null) { 115 return ""; 116 } 117 118 return UIStrings.get(sourceControlID); 119 } 120 121 122 /*** 123 * Sets the ID of the Control being executed when the error was detected. 124 * <br> 125 * For use by a ControlException handler only, not for application writers. 126 * 127 * @param inSourceControlID the ID of the {@link org.scopemvc.core.Control 128 * Control} executing when the error was detected. 129 */ 130 public final void setSourceControlID(String inSourceControlID) { 131 sourceControlID = inSourceControlID; 132 } 133 } 134

This page was automatically generated by Maven