001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: //-----------------------------------------------------------------------------
028: // PACKAGE DEFINITION
029: //-----------------------------------------------------------------------------
030: package sim.toolkit;
031:
032: //-----------------------------------------------------------------------------
033: // IMPORTS
034: //-----------------------------------------------------------------------------
035: import javacard.framework.*;
036:
037: /**
038: *
039: * This class extends the Throwable class and allows the classes of this package
040: * to throw specific exceptions in case of problems. <p>
041: *
042: * @version 8.3.0
043: */
044: public class ToolkitException extends CardRuntimeException {
045:
046: // ------------------------------- Constants ------------------------------
047: /**
048: * This reason code (= 1) is used to indicate that data are to
049: * large than the storage space available in the handler.
050: */
051: public static final short HANDLER_OVERFLOW = (short) 1;
052:
053: /**
054: * This reason code (= 2) is used to indicate that the Handler is
055: * not available (e.g. busy).
056: */
057: public static final short HANDLER_NOT_AVAILABLE = (short) 2;
058:
059: /**
060: * This reason code (= 3) is used to indicate that the element is
061: * unavailable in the handler buffer.
062: */
063: public static final short UNAVAILABLE_ELEMENT = (short) 3;
064:
065: /**
066: * This reason code (= 4) is used to indicate that the requested
067: * menu entry is not define for the corresponding applet.
068: */
069: public static final short MENU_ENTRY_NOT_FOUND = (short) 4;
070:
071: /**
072: * This reason code (= 5) is used to indicate an error in the
073: * applet registry.
074: */
075: public static final short REGISTRY_ERROR = (short) 5;
076:
077: /**
078: * This reason code (= 6) is used to indicate that the event code
079: * is not supported by the toolkit framework
080: */
081: public static final short EVENT_NOT_SUPPORTED = (short) 6;
082:
083: /**
084: * This reason code (= 7) is used to indicate that the maximum
085: * number of registered applet for this event is already reached
086: * (e.g Call Control)
087: */
088: public static final short EVENT_ALREADY_REGISTERED = (short) 7;
089:
090: /**
091: * This reason code (= 8) is used to indictae that either the
092: * offset, the length or both are out of current TLV boundaries.
093: */
094: public static final short OUT_OF_TLV_BOUNDARIES = (short) 8;
095:
096: /**
097: * This reason code (= 9) is used to indicate that the Terminal
098: * Profile data are not available
099: */
100: public static final short ME_PROFILE_NOT_AVAILABLE = (short) 9;
101:
102: /**
103: * This reason code (=10) is used to indicate that the provided
104: * menu entry string is bigger than the space alloacted space.
105: */
106: public static final short ALLOWED_LENGTH_EXCEEDED = (short) 10;
107:
108: /**
109: * This reason code (=11) is used to indicate that all the
110: * available timers or the maximum number of timers have been
111: * allocated to the applet.
112: */
113: public static final short NO_TIMER_AVAILABLE = (short) 11;
114:
115: /**
116: * This reason code (=12) is used to indicate that the indicated
117: * timer identifier is not allocated to this applet.
118: */
119: public static final short INVALID_TIMER_ID = (short) 12;
120:
121: /**
122: * This reason code (=13) is used to indicate that the
123: * registration to an indicated event can not be changed by the
124: * called method.
125: */
126: public static final short EVENT_NOT_ALLOWED = (short) 13;
127:
128: /**
129: * This reason code (=14) is used to indicate that an input
130: * parameter of the method is not valid.
131: */
132: public static final short BAD_INPUT_PARAMETER = (short) 14;
133:
134: // ------------------------------- Constructors ---------------------------
135: /**
136: * Construct a ToolkitException instance with the specified reason.
137: *
138: * @param reason the reason for the exception
139: */
140: public ToolkitException(short reason) {
141: super (reason);
142: }
143:
144: // ------------------------------- Public methods -------------------------
145: /**
146: * Throws the Toolkit Interface's instance of the
147: * <code>ToolkitException</code> class with the specified reason.
148: *
149: * @param reason the reason for the exception.
150: *
151: * @exception ToolkitException always
152: */
153: public static void throwIt(short reason) throws ToolkitException {
154: ToolkitException systemInstance = ViewHandler.currentTI
155: .getToolkitExceptionInstance();
156: systemInstance.setReason(reason);
157: throw systemInstance;
158: }
159: }
|