duke@1: /*
ohair@158: * Copyright (c) 1995, 2006, Oracle and/or its affiliates. All rights reserved.
duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1: *
duke@1: * This code is free software; you can redistribute it and/or modify it
duke@1: * under the terms of the GNU General Public License version 2 only, as
ohair@158: * published by the Free Software Foundation. Oracle designates this
duke@1: * particular file as subject to the "Classpath" exception as provided
ohair@158: * by Oracle in the LICENSE file that accompanied this code.
duke@1: *
duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1: * version 2 for more details (a copy is included in the LICENSE file that
duke@1: * accompanied this code).
duke@1: *
duke@1: * You should have received a copy of the GNU General Public License version
duke@1: * 2 along with this work; if not, write to the Free Software Foundation,
duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1: *
ohair@158: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@158: * or visit www.oracle.com if you need additional information or have any
ohair@158: * questions.
duke@1: */
duke@1:
duke@1: package org.omg.CORBA;
duke@1:
duke@1: import org.omg.CORBA.portable.InputStream;
duke@1: import org.omg.CORBA.portable.OutputStream;
duke@1: import java.util.*;
duke@1: import org.omg.CORBA.OMGVMCID;
duke@1: import com.sun.corba.se.impl.util.SUNVMCID;
duke@1:
duke@1: /**
duke@1: * The root class for all CORBA standard exceptions. These exceptions
duke@1: * may be thrown as a result of any CORBA operation invocation and may
duke@1: * also be returned by many standard CORBA API methods. The standard
duke@1: * exceptions contain a minor code, allowing more detailed specification, and a
duke@1: * completion status. This class is subclassed to
duke@1: * generate each one of the set of standard ORB exceptions.
duke@1: * SystemException
extends
duke@1: * java.lang.RuntimeException
; thus none of the
duke@1: * SystemException
exceptions need to be
duke@1: * declared in signatures of the Java methods mapped from operations in
duke@1: * IDL interfaces.
duke@1: *
duke@1: * @see documentation on
duke@1: * Java IDL exceptions
duke@1: */
duke@1:
duke@1: public abstract class SystemException extends java.lang.RuntimeException {
duke@1:
duke@1: /**
duke@1: * The CORBA Exception minor code.
duke@1: * @serial
duke@1: */
duke@1: public int minor;
duke@1:
duke@1: /**
duke@1: * The status of the operation that threw this exception.
duke@1: * @serial
duke@1: */
duke@1: public CompletionStatus completed;
duke@1:
duke@1: /**
duke@1: * Constructs a SystemException
exception with the specified detail
duke@1: * message, minor code, and completion status.
duke@1: * A detail message is a String that describes this particular exception.
duke@1: * @param reason the String containing a detail message
duke@1: * @param minor the minor code
duke@1: * @param completed the completion status
duke@1: */
duke@1: protected SystemException(String reason, int minor, CompletionStatus completed) {
duke@1: super(reason);
duke@1: this.minor = minor;
duke@1: this.completed = completed;
duke@1: }
duke@1:
duke@1: /**
duke@1: * Converts this exception to a representative string.
duke@1: */
duke@1: public String toString() {
duke@1: // The fully qualified exception class name
duke@1: String result = super.toString();
duke@1:
duke@1: // The vmcid part
duke@1: int vmcid = minor & 0xFFFFF000;
duke@1: switch (vmcid) {
duke@1: case OMGVMCID.value:
duke@1: result += " vmcid: OMG";
duke@1: break;
duke@1: case SUNVMCID.value:
duke@1: result += " vmcid: SUN";
duke@1: break;
duke@1: default:
duke@1: result += " vmcid: 0x" + Integer.toHexString(vmcid);
duke@1: break;
duke@1: }
duke@1:
duke@1: // The minor code part
duke@1: int mc = minor & 0x00000FFF;
duke@1: result += " minor code: " + mc;
duke@1:
duke@1: // The completion status part
duke@1: switch (completed.value()) {
duke@1: case CompletionStatus._COMPLETED_YES:
duke@1: result += " completed: Yes";
duke@1: break;
duke@1: case CompletionStatus._COMPLETED_NO:
duke@1: result += " completed: No";
duke@1: break;
duke@1: case CompletionStatus._COMPLETED_MAYBE:
duke@1: default:
duke@1: result += " completed: Maybe";
duke@1: break;
duke@1: }
duke@1: return result;
duke@1: }
duke@1: }