Source for org.omg.CORBA.ParameterMode

   1: /* ParameterMode.java --
   2:    Copyright (C) 2005, 2006 Free Software Foundation, Inc.
   3: 
   4: This file is part of GNU Classpath.
   5: 
   6: GNU Classpath is free software; you can redistribute it and/or modify
   7: it under the terms of the GNU General Public License as published by
   8: the Free Software Foundation; either version 2, or (at your option)
   9: any later version.
  10: 
  11: GNU Classpath is distributed in the hope that it will be useful, but
  12: WITHOUT ANY WARRANTY; without even the implied warranty of
  13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14: General Public License for more details.
  15: 
  16: You should have received a copy of the GNU General Public License
  17: along with GNU Classpath; see the file COPYING.  If not, write to the
  18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  19: 02110-1301 USA.
  20: 
  21: Linking this library statically or dynamically with other modules is
  22: making a combined work based on this library.  Thus, the terms and
  23: conditions of the GNU General Public License cover the whole
  24: combination.
  25: 
  26: As a special exception, the copyright holders of this library give you
  27: permission to link this library with independent modules to produce an
  28: executable, regardless of the license terms of these independent
  29: modules, and to copy and distribute the resulting executable under
  30: terms of your choice, provided that you also meet, for each linked
  31: independent module, the terms and conditions of the license of that
  32: module.  An independent module is a module which is not derived from
  33: or based on this library.  If you modify this library, you may extend
  34: this exception to your version of the library, but you are not
  35: obligated to do so.  If you do not wish to do so, delete this
  36: exception statement from your version. */
  37: 
  38: package org.omg.CORBA;
  39: 
  40: import org.omg.CORBA.portable.IDLEntity;
  41: 
  42: import java.io.Serializable;
  43: 
  44: /**
  45:  * Defines the parameter modes (the ways in that a method parameter
  46:  * is used during invocation).
  47:  *
  48:  * In CORBA, a method parameter can pass the value (PARAM_IN),
  49:  * be used as a placeholder to return the value (PARAM_OUT) or
  50:  * both pass the data and be used as a placeholder to return the
  51:  * changed value (PARAM_INOUT).
  52:  *
  53:  * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
  54:  */
  55: public class ParameterMode
  56:   implements Serializable, IDLEntity
  57: {
  58:   /**
  59:    * Use serialVersionUID (v1.4) for interoperability.
  60:    */
  61:   private static final long serialVersionUID = 1521598391932998229L;
  62: 
  63:   /**
  64:    * This value means that the parameter is an IN parameter.
  65:    */
  66:   public static final int _PARAM_IN = 0;
  67: 
  68:   /**
  69:    * This value means that the parameter is an OUT parameter.
  70:    */
  71:   public static final int _PARAM_OUT = 1;
  72: 
  73:   /**
  74:    * This value means that the parameter is an INOUT parameter.
  75:    */
  76:   public static final int _PARAM_INOUT = 2;
  77: 
  78:   /**
  79:    * This value means that the parameter is an IN parameter.
  80:    */
  81:   public static final ParameterMode PARAM_IN = new ParameterMode(_PARAM_IN);
  82: 
  83:   /**
  84:    * This value means that the parameter is an OUT parameter.
  85:    */
  86:   public static final ParameterMode PARAM_OUT = new ParameterMode(_PARAM_OUT);
  87: 
  88:   /**
  89:    * This value means that the parameter is an INOUT parameter.
  90:    */
  91:   public static final ParameterMode PARAM_INOUT = new ParameterMode(_PARAM_INOUT);
  92: 
  93:   /**
  94:    * The value of this parameter mode instance.
  95:    */
  96:   private final int value;
  97: 
  98:   /**
  99:    * The conversion table.
 100:    */
 101:   private static final ParameterMode[] table =
 102:     new ParameterMode[] { PARAM_IN, PARAM_OUT, PARAM_INOUT };
 103: 
 104:   /**
 105:    * Create an instance of the parameter mode with the given value.
 106:    */
 107:   protected ParameterMode(int a_value)
 108:   {
 109:     value = a_value;
 110:   }
 111: 
 112:   /**
 113:    * Return the integer value code for the given parameter mode.
 114:    *
 115:    * @return 0 for PARAM_IN, 1 for PARAM_OUT, 3 for PARAM_INOUT.
 116:    */
 117:   public int value()
 118:   {
 119:     return value;
 120:   }
 121: 
 122:   /**
 123:    * Get a parameter mode instance for the integer parameter mode code.
 124:    *
 125:    * @param p_mode a parameter mode (0..2).
 126:    *
 127:    * @return a corresponding parameter mode instance.
 128:    *
 129:    * @throws BAD_PARAM for the invalid parameter mode code.
 130:    */
 131:   public static ParameterMode from_int(int p_mode)
 132:   {
 133:     try
 134:       {
 135:         return table [ p_mode ];
 136:       }
 137:     catch (ArrayIndexOutOfBoundsException ex)
 138:       {
 139:         throw new BAD_PARAM("Invalid parameter mode: " + p_mode);
 140:       }
 141:   }