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