001: /*
002: * Copyright 1995-2006 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package org.omg.CORBA;
027:
028: import org.omg.CORBA.portable.InputStream;
029: import org.omg.CORBA.portable.OutputStream;
030: import java.util.*;
031: import org.omg.CORBA.OMGVMCID;
032: import com.sun.corba.se.impl.util.SUNVMCID;
033:
034: /**
035: * The root class for all CORBA standard exceptions. These exceptions
036: * may be thrown as a result of any CORBA operation invocation and may
037: * also be returned by many standard CORBA API methods. The standard
038: * exceptions contain a minor code, allowing more detailed specification, and a
039: * completion status. This class is subclassed to
040: * generate each one of the set of standard ORB exceptions.
041: * <code>SystemException</code> extends
042: * <code>java.lang.RuntimeException</code>; thus none of the
043: * <code>SystemException</code> exceptions need to be
044: * declared in signatures of the Java methods mapped from operations in
045: * IDL interfaces.
046: *
047: * @see <A href="../../../../technotes/guides/idl/jidlExceptions.html">documentation on
048: * Java IDL exceptions</A>
049: */
050:
051: public abstract class SystemException extends
052: java.lang.RuntimeException {
053:
054: /**
055: * The CORBA Exception minor code.
056: * @serial
057: */
058: public int minor;
059:
060: /**
061: * The status of the operation that threw this exception.
062: * @serial
063: */
064: public CompletionStatus completed;
065:
066: /**
067: * Constructs a <code>SystemException</code> exception with the specified detail
068: * message, minor code, and completion status.
069: * A detail message is a String that describes this particular exception.
070: * @param reason the String containing a detail message
071: * @param minor the minor code
072: * @param completed the completion status
073: */
074: protected SystemException(String reason, int minor,
075: CompletionStatus completed) {
076: super (reason);
077: this .minor = minor;
078: this .completed = completed;
079: }
080:
081: /**
082: * Converts this exception to a representative string.
083: */
084: public String toString() {
085: // The fully qualified exception class name
086: String result = super .toString();
087:
088: // The vmcid part
089: int vmcid = minor & 0xFFFFF000;
090: switch (vmcid) {
091: case OMGVMCID.value:
092: result += " vmcid: OMG";
093: break;
094: case SUNVMCID.value:
095: result += " vmcid: SUN";
096: break;
097: default:
098: result += " vmcid: 0x" + Integer.toHexString(vmcid);
099: break;
100: }
101:
102: // The minor code part
103: int mc = minor & 0x00000FFF;
104: result += " minor code: " + mc;
105:
106: // The completion status part
107: switch (completed.value()) {
108: case CompletionStatus._COMPLETED_YES:
109: result += " completed: Yes";
110: break;
111: case CompletionStatus._COMPLETED_NO:
112: result += " completed: No";
113: break;
114: case CompletionStatus._COMPLETED_MAYBE:
115: default:
116: result += " completed: Maybe";
117: break;
118: }
119: return result;
120: }
121: }
|