1. /*
  2. * @(#)SetOverrideType.java 1.15 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package org.omg.CORBA;
  8. /**
  9. * The mapping of a CORBA <code>enum</code> tagging
  10. * <code>SET_OVERRIDE</code> and <code>ADD_OVERRIDE</code>, which
  11. * indicate whether policies should replace the
  12. * existing policies of an <code>Object</code> or be added to them.
  13. * <P>
  14. * The method {@link omg.org.CORBA.Object._set_policy_override} takes
  15. * either <code>SetOverrideType.SET_OVERRIDE</code> or
  16. * <code>SetOverrideType.ADD_OVERRIDE</code> as its second argument.
  17. * The method <code>_set_policy_override</code>
  18. * creates a new <code>Object</code> initialized with the
  19. * <code>Policy</code> objects supplied as the first argument. If the
  20. * second argument is <code>ADD_OVERRIDE</code>, the new policies
  21. * are added to those of the <code>Object</code> instance that is
  22. * calling the <code>_set_policy_override</code> method. If
  23. * <code>SET_OVERRIDE</code> is given instead, the existing policies
  24. * are replaced with the given ones.
  25. *
  26. * @author OMG
  27. * @version 1.15 12/19/03
  28. * @since JDK1.2
  29. */
  30. public class SetOverrideType implements org.omg.CORBA.portable.IDLEntity {
  31. /**
  32. * The <code>int</code> constant for the enum value SET_OVERRIDE.
  33. */
  34. public static final int _SET_OVERRIDE = 0;
  35. /**
  36. * The <code>int</code> constant for the enum value ADD_OVERRIDE.
  37. */
  38. public static final int _ADD_OVERRIDE = 1;
  39. /**
  40. * The <code>SetOverrideType</code> constant for the enum value SET_OVERRIDE.
  41. */
  42. public static final SetOverrideType SET_OVERRIDE = new SetOverrideType(_SET_OVERRIDE);
  43. /**
  44. * The <code>SetOverrideType</code> constant for the enum value ADD_OVERRIDE.
  45. */
  46. public static final SetOverrideType ADD_OVERRIDE = new SetOverrideType(_ADD_OVERRIDE);
  47. /**
  48. * Retrieves the value of this <code>SetOverrideType</code> instance.
  49. *
  50. * @return the <code>int</code> for this <code>SetOverrideType</code> instance.
  51. */
  52. public int value() {
  53. return _value;
  54. }
  55. /**
  56. * Converts the given <code>int</code> to the corresponding
  57. * <code>SetOverrideType</code> instance.
  58. *
  59. * @param i the <code>int</code> to convert; must be either
  60. * <code>SetOverrideType._SET_OVERRIDE</code> or
  61. * <code>SetOverrideType._ADD_OVERRIDE</code>
  62. * @return the <code>SetOverrideType</code> instance whose value
  63. * matches the given <code>int</code>
  64. * @exception BAD_PARAM if the given <code>int</code> does not
  65. * match the value of
  66. * any <code>SetOverrideType</code> instance
  67. */
  68. public static SetOverrideType from_int(int i)
  69. {
  70. switch (i) {
  71. case _SET_OVERRIDE:
  72. return SET_OVERRIDE;
  73. case _ADD_OVERRIDE:
  74. return ADD_OVERRIDE;
  75. default:
  76. throw new org.omg.CORBA.BAD_PARAM();
  77. }
  78. }
  79. /**
  80. * Constructs a <code>SetOverrideType</code> instance from an
  81. * <code>int</code>.
  82. * @param _value must be either <code>SET_OVERRIDE</code> or
  83. * <code>ADD_OVERRIDE</code>
  84. */
  85. protected SetOverrideType(int _value){
  86. this._value = _value;
  87. }
  88. /**
  89. * The field containing the value for this <code>SetOverrideType</code>
  90. * object.
  91. *
  92. */
  93. private int _value;
  94. }