001 /* BindingType.java --
002 Copyright (C) 2005, 2006 Free Software Foundation, Inc.
003
004 This file is part of GNU Classpath.
005
006 GNU Classpath is free software; you can redistribute it and/or modify
007 it under the terms of the GNU General Public License as published by
008 the Free Software Foundation; either version 2, or (at your option)
009 any later version.
010
011 GNU Classpath is distributed in the hope that it will be useful, but
012 WITHOUT ANY WARRANTY; without even the implied warranty of
013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014 General Public License for more details.
015
016 You should have received a copy of the GNU General Public License
017 along with GNU Classpath; see the file COPYING. If not, write to the
018 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
019 02110-1301 USA.
020
021 Linking this library statically or dynamically with other modules is
022 making a combined work based on this library. Thus, the terms and
023 conditions of the GNU General Public License cover the whole
024 combination.
025
026 As a special exception, the copyright holders of this library give you
027 permission to link this library with independent modules to produce an
028 executable, regardless of the license terms of these independent
029 modules, and to copy and distribute the resulting executable under
030 terms of your choice, provided that you also meet, for each linked
031 independent module, the terms and conditions of the license of that
032 module. An independent module is a module which is not derived from
033 or based on this library. If you modify this library, you may extend
034 this exception to your version of the library, but you are not
035 obligated to do so. If you do not wish to do so, delete this
036 exception statement from your version. */
037
038
039 package org.omg.CosNaming;
040
041 import org.omg.CORBA.BAD_PARAM;
042
043 /**
044 * Specifies the binding type (how the binding has been created).
045 *
046 * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
047 */
048 public class BindingType
049 implements org.omg.CORBA.portable.IDLEntity
050 {
051 /**
052 * Use serialVersionUID (v1.4) for interoperability.
053 */
054 private static final long serialVersionUID = 3735105633408228513L;
055
056 /**
057 * This constant means that the binding has been created
058 * with operations bind_context, rebind_context or
059 * bind_new_context.
060 */
061 public static final int _ncontext = 1;
062
063 /**
064 * This constant means that the binding has been created by the
065 * means, different from the listed in {@link #_ncontext} description.
066 */
067 public static final int _nobject = 0;
068
069 /**
070 * This constant means that the binding has been created
071 * with operations bind_context, rebind_context or
072 * bind_new_context.
073 */
074 public static final BindingType ncontext = new BindingType(_ncontext);
075
076 /**
077 * This constant means that the binding has been created by the
078 * means, different from the listed in {@link #_ncontext} description.
079 */
080 public static final BindingType nobject = new BindingType(_nobject);
081
082 /**
083 * The binding type, defined by this instance.
084 */
085 private final int type;
086
087 /**
088 * Create the new binding type definition.
089 *
090 * @param value the binding type, normally either _nobject or
091 * _ncontext.
092 */
093 protected BindingType(int value)
094 {
095 type = value;
096 }
097
098 /**
099 * Get the binding type instance, matching its integer code.
100 *
101 * @param value the binding type code.
102 * @return the matching binding type instance.
103 *
104 * @throws BAD_PARAM if there is no matching binding type for
105 * the passed value.
106 */
107 public static BindingType from_int(int value)
108 {
109 switch (value)
110 {
111 case _nobject :
112 return nobject;
113
114 case _ncontext :
115 return ncontext;
116
117 default :
118 throw new BAD_PARAM("Unsupported binding type code " + value);
119 }
120 }
121
122 /**
123 * Return the integer code for this binding.
124 */
125 public int value()
126 {
127 return type;
128 }
129 }