1. /*
  2. * @(#)BooleanHolder.java 1.25 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>boolean</code>
  13. * that is used to store "out" and "inout" parameters in IDL methods.
  14. * If an IDL method signature has an IDL <code>boolean</code> as an "out"
  15. * or "inout" parameter, the programmer must pass an instance of
  16. * <code>BooleanHolder</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>myBooleanHolder</code> is an instance of <code>BooleanHolder</code>,
  23. * the value stored in its <code>value</code> field can be accessed with
  24. * <code>myBooleanHolder.value</code>.
  25. *
  26. * @version 1.14, 09/09/97
  27. * @since JDK1.2
  28. */
  29. public final class BooleanHolder implements Streamable {
  30. /**
  31. * The <code>boolean</code> value held by this <code>BooleanHolder</code>
  32. * object.
  33. */
  34. public boolean value;
  35. /**
  36. * Constructs a new <code>BooleanHolder</code> object with its
  37. * <code>value</code> field initialized to <code>false</code>.
  38. */
  39. public BooleanHolder() {
  40. }
  41. /**
  42. * Constructs a new <code>BooleanHolder</code> object with its
  43. * <code>value</code> field initialized with the given <code>boolean</code>.
  44. * @param initial the <code>boolean</code> with which to initialize
  45. * the <code>value</code> field of the newly-created
  46. * <code>BooleanHolder</code> object
  47. */
  48. public BooleanHolder(boolean initial) {
  49. value = initial;
  50. }
  51. /**
  52. * Reads unmarshalled data from <code>input</code> and assigns it to this
  53. * <code>BooleanHolder</code> object's <code>value</code> field.
  54. *
  55. * @param input the <code>InputStream</code> object containing
  56. * CDR formatted data from the wire
  57. */
  58. public void _read(InputStream input) {
  59. value = input.read_boolean();
  60. }
  61. /**
  62. * Marshals the value in this <code>BooleanHolder</code> object's
  63. * <code>value</code> field to the output stream <code>output</code>.
  64. *
  65. * @param output the OutputStream which will contain the CDR formatted data
  66. */
  67. public void _write(OutputStream output) {
  68. output.write_boolean(value);
  69. }
  70. /**
  71. * Retrieves the <code>TypeCode</code> object that corresponds to the
  72. * value held in this <code>BooleanHolder</code> object.
  73. *
  74. * @return the <code>TypeCode</code> for the value held
  75. * in this <code>BooleanHolder</code> object
  76. */
  77. public TypeCode _type() {
  78. return ORB.init().get_primitive_tc(TCKind.tk_boolean);
  79. }
  80. }