1. /*
  2. * @(#)CompletionStatus.java 1.16 00/02/02
  3. *
  4. * Copyright 1996-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package org.omg.CORBA;
  11. /**
  12. * An object that indicates whether a method had completed running
  13. * when a <code>SystemException</code> was thrown.
  14. * <P>
  15. * The class <code>CompletionStatus</code>
  16. * contains three <code>CompletionStatus</code> instances, which are constants
  17. * representing each
  18. * possible completion status: <code>COMPLETED_MAYBE</code>,
  19. * <code>COMPLETED_NO</code>, and <code>COMPLETED_YES</code>.
  20. * It also contains
  21. * three <code>int</code> members, each a constant corresponding to one of
  22. * the <code>CompletionStatus</code> instances. These <code>int</code>
  23. * members make it possible to use a <code>switch</code> statement.
  24. * <P>
  25. * The class also contains two methods:
  26. * <UL>
  27. * <LI><code>public int <bold>value</bold>()</code> -- which accesses the
  28. * <code>value</code> field of a <code>CompletionStatus</code> object
  29. * <LI><code>public static CompletionStatus
  30. * <bold>from_int</bold>(int i)</code> --
  31. * for creating an instance from one of the <code>int</code> members
  32. * </UL>
  33. * @version %I, %G
  34. * @see org.omg.CORBA.SystemException
  35. * @since JDK1.2
  36. */
  37. public class CompletionStatus implements org.omg.CORBA.portable.IDLEntity
  38. {
  39. /**
  40. * The constant indicating that a method completed running
  41. * before a <code>SystemException</code> was thrown.
  42. */
  43. public static final int _COMPLETED_YES = 0,
  44. /**
  45. * The constant indicating that a method had not completed running
  46. * when a <code>SystemException</code> was thrown.
  47. */
  48. _COMPLETED_NO = 1,
  49. /**
  50. * The constant indicating that it is unknown whether a method had
  51. * completed running when a <code>SystemException</code> was thrown.
  52. */
  53. _COMPLETED_MAYBE = 2;
  54. /**
  55. * An instance of <code>CompletionStatus</code> initialized with
  56. * the constant <code>_COMPLETED_YES</code>.
  57. */
  58. public static final CompletionStatus COMPLETED_YES = new CompletionStatus(_COMPLETED_YES);
  59. /**
  60. * An instance of <code>CompletionStatus</code> initialized with
  61. * the constant <code>_COMPLETED_NO</code>.
  62. */
  63. public static final CompletionStatus COMPLETED_NO = new CompletionStatus(_COMPLETED_NO);
  64. /**
  65. * An instance of <code>CompletionStatus</code> initialized with
  66. * the constant <code>_COMPLETED_MAYBE</code>.
  67. */
  68. public static final CompletionStatus COMPLETED_MAYBE = new CompletionStatus(_COMPLETED_MAYBE);
  69. /**
  70. * Retrieves the value of this <code>CompletionStatus</code> object.
  71. *
  72. * @return one of the possible <code>CompletionStatus</code> values:
  73. * <code>_COMPLETED_YES</code>, <code>_COMPLETED_NO</code>, or
  74. * <code>_COMPLETED_MAYBE</code>
  75. *
  76. */
  77. public int value() { return _value; }
  78. /**
  79. * Creates a <code>CompletionStatus</code> object from the given <code>int</code>.
  80. *
  81. * @param i one of <code>_COMPLETED_YES</code>, <code>_COMPLETED_NO</code>, or
  82. * <code>_COMPLETED_MAYBE</code>
  83. *
  84. * @return one of the possible <code>CompletionStatus</code> objects
  85. * with values:
  86. * <code>_COMPLETED_YES</code>, <code>_COMPLETED_NO</code>, or
  87. * <code>_COMPLETED_MAYBE</code>
  88. *
  89. * @exception org.omg.CORBA.BAD_PARAM if the argument given is not one of the
  90. * <code>int</code> constants defined in <code>CompletionStatus</code>
  91. */
  92. public static CompletionStatus from_int(int i) throws org.omg.CORBA.BAD_PARAM {
  93. switch (i) {
  94. case _COMPLETED_YES:
  95. return COMPLETED_YES;
  96. case _COMPLETED_NO:
  97. return COMPLETED_NO;
  98. case _COMPLETED_MAYBE:
  99. return COMPLETED_MAYBE;
  100. default:
  101. throw new org.omg.CORBA.BAD_PARAM();
  102. }
  103. }
  104. /**
  105. * Creates a <code>CompletionStatus</code> object from the given <code>int</code>.
  106. *
  107. * @param _value one of <code>_COMPLETED_YES</code>, <code>_COMPLETED_NO</code>, or
  108. * <code>_COMPLETED_MAYBE</code>
  109. *
  110. */
  111. protected CompletionStatus(int _value) {
  112. this._value = _value;
  113. }
  114. private int _value;
  115. }