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