1. /*
  2. * @(#)ValueBaseHolder.java 1.7 00/02/02
  3. *
  4. * Copyright 1995-2000 Sun Microsystems, Inc. All Rights Reserved.
  5. *
  6. * This software is the proprietary information of Sun Microsystems, Inc.
  7. * Use is subject to license terms.
  8. *
  9. */
  10. package org.omg.CORBA;
  11. import org.omg.CORBA.portable.Streamable;
  12. import org.omg.CORBA.portable.InputStream;
  13. import org.omg.CORBA.portable.OutputStream;
  14. /**
  15. * A Holder class for a <code>java.io.Serializable</code>
  16. * that is used to store "out" and "inout" parameters in IDL methods.
  17. * If an IDL method signature has an IDL <code>ValueBase</code> as an "out"
  18. * or "inout" parameter, the programmer must pass an instance of
  19. * <code>ValueBaseHolder</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>myValueBaseHolder</code> is an instance of <code>ValueBaseHolder</code>,
  26. * the value stored in its <code>value</code> field can be accessed with
  27. * <code>myValueBaseHolder.value</code>.
  28. *
  29. */
  30. public final class ValueBaseHolder implements Streamable {
  31. /**
  32. * The <code>java.io.Serializable</code> value held by this
  33. * <code>ValueBaseHolder</code> object.
  34. */
  35. public java.io.Serializable value;
  36. /**
  37. * Constructs a new <code>ValueBaseHolder</code> object with its
  38. * <code>value</code> field initialized to <code>0</code>.
  39. */
  40. public ValueBaseHolder() {
  41. }
  42. /**
  43. * Constructs a new <code>ValueBaseHolder</code> object with its
  44. * <code>value</code> field initialized to the given
  45. * <code>java.io.Serializable</code>.
  46. * @param initial the <code>java.io.Serializable</code> with which to initialize
  47. * the <code>value</code> field of the newly-created
  48. * <code>ValueBaseHolder</code> object
  49. */
  50. public ValueBaseHolder(java.io.Serializable initial) {
  51. value = initial;
  52. }
  53. /**
  54. * Reads from <code>input</code> and initalizes the value in the Holder
  55. * with the unmarshalled data.
  56. *
  57. * @param input the InputStream containing CDR formatted data from the wire
  58. */
  59. public void _read(InputStream input) {
  60. value = ((org.omg.CORBA_2_3.portable.InputStream)input).read_value();
  61. }
  62. /**
  63. * Marshals to <code>output</code> the value in the Holder.
  64. *
  65. * @param output the OutputStream which will contain the CDR formatted data
  66. */
  67. public void _write(OutputStream output) {
  68. ((org.omg.CORBA_2_3.portable.OutputStream)output).write_value(value);
  69. }
  70. /**
  71. * Returns the <code>TypeCode</code> object
  72. * corresponding to the value held in the Holder.
  73. *
  74. * @return the TypeCode of the value held in the holder
  75. */
  76. public org.omg.CORBA.TypeCode _type() {
  77. return ORB.init().get_primitive_tc(TCKind.tk_value);
  78. }
  79. }