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