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