SetOverrideType.java revision 608:7e06bf1dcb09
1178476Sjb/* 2178476Sjb * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. 3178476Sjb * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4178476Sjb * 5178476Sjb * This code is free software; you can redistribute it and/or modify it 6178476Sjb * under the terms of the GNU General Public License version 2 only, as 7178476Sjb * published by the Free Software Foundation. Oracle designates this 8178476Sjb * particular file as subject to the "Classpath" exception as provided 9178476Sjb * by Oracle in the LICENSE file that accompanied this code. 10178476Sjb * 11178476Sjb * This code is distributed in the hope that it will be useful, but WITHOUT 12178476Sjb * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13178476Sjb * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14178476Sjb * version 2 for more details (a copy is included in the LICENSE file that 15178476Sjb * accompanied this code). 16178476Sjb * 17178476Sjb * You should have received a copy of the GNU General Public License version 18178476Sjb * 2 along with this work; if not, write to the Free Software Foundation, 19178476Sjb * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20178476Sjb * 21178476Sjb * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22178476Sjb * or visit www.oracle.com if you need additional information or have any 23178476Sjb * questions. 24178476Sjb */ 25178476Sjb 26178476Sjbpackage org.omg.CORBA; 27178476Sjb 28178476Sjb/** 29178476Sjb * The mapping of a CORBA <code>enum</code> tagging 30178476Sjb * <code>SET_OVERRIDE</code> and <code>ADD_OVERRIDE</code>, which 31178476Sjb * indicate whether policies should replace the 32178476Sjb * existing policies of an <code>Object</code> or be added to them. 33178476Sjb * <P> 34178476Sjb * The method {@link org.omg.CORBA.Object#_set_policy_override} takes 35178476Sjb * either <code>SetOverrideType.SET_OVERRIDE</code> or 36178476Sjb * <code>SetOverrideType.ADD_OVERRIDE</code> as its second argument. 37178476Sjb * The method <code>_set_policy_override</code> 38178476Sjb * creates a new <code>Object</code> initialized with the 39178476Sjb * <code>Policy</code> objects supplied as the first argument. If the 40178476Sjb * second argument is <code>ADD_OVERRIDE</code>, the new policies 41178476Sjb * are added to those of the <code>Object</code> instance that is 42178476Sjb * calling the <code>_set_policy_override</code> method. If 43178476Sjb * <code>SET_OVERRIDE</code> is given instead, the existing policies 44178476Sjb * are replaced with the given ones. 45178476Sjb * 46178476Sjb * @author OMG 47178476Sjb * @since JDK1.2 48178476Sjb */ 49178476Sjb 50178476Sjbpublic class SetOverrideType implements org.omg.CORBA.portable.IDLEntity { 51178476Sjb 52178476Sjb /** 53178476Sjb * The <code>int</code> constant for the enum value SET_OVERRIDE. 54178476Sjb */ 55178476Sjb public static final int _SET_OVERRIDE = 0; 56178476Sjb 57178476Sjb /** 58178476Sjb * The <code>int</code> constant for the enum value ADD_OVERRIDE. 59211545Srpaulo */ 60178476Sjb public static final int _ADD_OVERRIDE = 1; 61178476Sjb 62178476Sjb /** 63178476Sjb * The <code>SetOverrideType</code> constant for the enum value SET_OVERRIDE. 64 */ 65 public static final SetOverrideType SET_OVERRIDE = new SetOverrideType(_SET_OVERRIDE); 66 67 /** 68 * The <code>SetOverrideType</code> constant for the enum value ADD_OVERRIDE. 69 */ 70 public static final SetOverrideType ADD_OVERRIDE = new SetOverrideType(_ADD_OVERRIDE); 71 72 /** 73 * Retrieves the value of this <code>SetOverrideType</code> instance. 74 * 75 * @return the <code>int</code> for this <code>SetOverrideType</code> instance. 76 */ 77 public int value() { 78 return _value; 79 } 80 81 /** 82 * Converts the given <code>int</code> to the corresponding 83 * <code>SetOverrideType</code> instance. 84 * 85 * @param i the <code>int</code> to convert; must be either 86 * <code>SetOverrideType._SET_OVERRIDE</code> or 87 * <code>SetOverrideType._ADD_OVERRIDE</code> 88 * @return the <code>SetOverrideType</code> instance whose value 89 * matches the given <code>int</code> 90 * @exception BAD_PARAM if the given <code>int</code> does not 91 * match the value of 92 * any <code>SetOverrideType</code> instance 93 */ 94 public static SetOverrideType from_int(int i) 95 { 96 switch (i) { 97 case _SET_OVERRIDE: 98 return SET_OVERRIDE; 99 case _ADD_OVERRIDE: 100 return ADD_OVERRIDE; 101 default: 102 throw new org.omg.CORBA.BAD_PARAM(); 103 } 104 } 105 106 /** 107 * Constructs a <code>SetOverrideType</code> instance from an 108 * <code>int</code>. 109 * @param _value must be either <code>SET_OVERRIDE</code> or 110 * <code>ADD_OVERRIDE</code> 111 */ 112 protected SetOverrideType(int _value){ 113 this._value = _value; 114 } 115 116 /** 117 * The field containing the value for this <code>SetOverrideType</code> 118 * object. 119 * 120 */ 121 private int _value; 122} 123