1. /*
  2. * @(#)SystemException.java 1.56 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package org.omg.CORBA;
  8. import org.omg.CORBA.portable.InputStream;
  9. import org.omg.CORBA.portable.OutputStream;
  10. import java.util.*;
  11. import org.omg.CORBA.OMGVMCID;
  12. import com.sun.corba.se.internal.util.SUNVMCID;
  13. /**
  14. * The root class for all CORBA standard exceptions. These exceptions
  15. * may be thrown as a result of any CORBA operation invocation and may
  16. * also be returned by many standard CORBA API methods. The standard
  17. * exceptions contain a minor code, allowing more detailed specification, and a
  18. * completion status. This class is subclassed to
  19. * generate each one of the set of standard ORB exceptions.
  20. * <code>SystemException</code> extends
  21. * <code>java.lang.RuntimeException</code> thus none of the
  22. * <code>SystemException</code> exceptions need to be
  23. * declared in signatures of the Java methods mapped from operations in
  24. * IDL interfaces.
  25. *
  26. * @see <A href="../../../../guide/idl/jidlExceptions.html">documentation on
  27. * Java IDL exceptions</A>
  28. */
  29. public abstract class SystemException extends java.lang.RuntimeException {
  30. /**
  31. * The CORBA Exception minor code.
  32. * @serial
  33. */
  34. public int minor;
  35. /**
  36. * The status of the operation that threw this exception.
  37. * @serial
  38. */
  39. public CompletionStatus completed;
  40. /**
  41. * Constructs a <code>SystemException</code> exception with the specified detail
  42. * message, minor code, and completion status.
  43. * A detail message is a String that describes this particular exception.
  44. * @param reason the String containing a detail message
  45. * @param minor the minor code
  46. * @param completed the completion status
  47. */
  48. protected SystemException(String reason, int minor, CompletionStatus completed) {
  49. super(reason);
  50. this.minor = minor;
  51. this.completed = completed;
  52. }
  53. /**
  54. * Converts this exception to a representative string.
  55. */
  56. public String toString() {
  57. // The fully qualified exception class name
  58. String result = super.toString();
  59. // The vmcid part
  60. int vmcid = minor & 0xFFFFF000;
  61. switch (vmcid) {
  62. case OMGVMCID.value:
  63. result += " vmcid: OMG";
  64. break;
  65. case SUNVMCID.value:
  66. result += " vmcid: SUN";
  67. break;
  68. default:
  69. result += " vmcid: 0x" + Integer.toHexString(vmcid);
  70. break;
  71. }
  72. // The minor code part
  73. int mc = minor & 0x00000FFF;
  74. result += " minor code: " + mc;
  75. // The completion status part
  76. switch (completed.value()) {
  77. case CompletionStatus._COMPLETED_YES:
  78. result += " completed: Yes";
  79. break;
  80. case CompletionStatus._COMPLETED_NO:
  81. result += " completed: No";
  82. break;
  83. case CompletionStatus._COMPLETED_MAYBE:
  84. default:
  85. result += " completed: Maybe";
  86. break;
  87. }
  88. return result;
  89. }
  90. }