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