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