1. /*
  2. * @(#)FloatHolder.java 1.28 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. import org.omg.CORBA.portable.Streamable;
  9. import org.omg.CORBA.portable.InputStream;
  10. import org.omg.CORBA.portable.OutputStream;
  11. /**
  12. * The Holder for <tt>Float</tt>. For more information on
  13. * Holder files, see <a href="doc-files/generatedfiles.html#holder">
  14. * "Generated Files: Holder Files"</a>.<P>
  15. * A Holder class for a <code>float</code>
  16. * that is used to store "out" and "inout" parameters in IDL methods.
  17. * If an IDL method signature has an IDL <code>float</code> as an "out"
  18. * or "inout" parameter, the programmer must pass an instance of
  19. * <code>FloatHolder</code> as the corresponding
  20. * parameter in the method invocation; for "inout" parameters, the programmer
  21. * must also fill the "in" value to be sent to the server.
  22. * Before the method invocation returns, the ORB will fill in the
  23. * value corresponding to the "out" value returned from the server.
  24. * <P>
  25. * If <code>myFloatHolder</code> is an instance of <code>FloatHolder</code>,
  26. * the value stored in its <code>value</code> field can be accessed with
  27. * <code>myFloatHolder.value</code>.
  28. *
  29. * @version 1.14, 09/09/97
  30. * @since JDK1.2
  31. */
  32. public final class FloatHolder implements Streamable {
  33. /**
  34. * The <code>float</code> value held by this <code>FloatHolder</code>
  35. * object.
  36. */
  37. public float value;
  38. /**
  39. * Constructs a new <code>FloatHolder</code> object with its
  40. * <code>value</code> field initialized to 0.0.
  41. */
  42. public FloatHolder() {
  43. }
  44. /**
  45. * Constructs a new <code>FloatHolder</code> object for the given
  46. * <code>float</code>.
  47. * @param initial the <code>float</code> with which to initialize
  48. * the <code>value</code> field of the new
  49. * <code>FloatHolder</code> object
  50. */
  51. public FloatHolder(float initial) {
  52. value = initial;
  53. }
  54. /**
  55. * Read a float from an input stream and initialize the value
  56. * member with the float value.
  57. *
  58. * @param input the <code>InputStream</code> to read from.
  59. */
  60. public void _read(InputStream input) {
  61. value = input.read_float();
  62. }
  63. /**
  64. * Write the float value into an output stream.
  65. *
  66. * @param output the <code>OutputStream</code> to write into.
  67. */
  68. public void _write(OutputStream output) {
  69. output.write_float(value);
  70. }
  71. /**
  72. * Return the <code>TypeCode</code> of this Streamable.
  73. *
  74. * @return the <code>TypeCode</code> object.
  75. */
  76. public org.omg.CORBA.TypeCode _type() {
  77. return ORB.init().get_primitive_tc(TCKind.tk_float);
  78. }
  79. }