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