1. /*
  2. * @(#)TypeCodeHolder.java 1.24 01/11/29
  3. *
  4. * Copyright 2002 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. * A Holder class for a <code>TypeCode</code> object
  13. * that is used to store "out" and "inout" parameters in IDL operations.
  14. * If an IDL operation signature has an IDL <code>TypeCode</code> as an "out"
  15. * or "inout" parameter, the programmer must pass an instance of
  16. * <code>TypeCodeHolder</code> as the corresponding
  17. * parameter in the method invocation; for "inout" parameters, the programmer
  18. * must also fill the "in" value to be sent to the server.
  19. * Before the method invocation returns, the ORB will fill in the
  20. * value corresponding to the "out" value returned from the server.
  21. * <P>
  22. * If <code>myTypeCodeHolder</code> is an instance of <code>TypeCodeHolder</code>,
  23. * the value stored in its <code>value</code> field can be accessed with
  24. * <code>myTypeCodeHolder.value</code>.
  25. *
  26. * @version 1.14, 09/09/97
  27. * @since JDK1.2
  28. */
  29. public final class TypeCodeHolder implements Streamable {
  30. /**
  31. * The <code>TypeCode</code> value held by
  32. * this <code>TypeCodeHolder</code> object.
  33. */
  34. public TypeCode value;
  35. /**
  36. * Constructs a new <code>TypeCodeHolder</code> object with its
  37. * <code>value</code> field initialized to <code>null</code>.
  38. */
  39. public TypeCodeHolder() {
  40. }
  41. /**
  42. * Constructs a new <code>TypeCodeHolder</code> object with its
  43. * <code>value</code> field initialized to the given
  44. * <code>TypeCode</code> object.
  45. * @param initial the <code>TypeCode</code> object with which to initialize
  46. * the <code>value</code> field of the newly-created
  47. * <code>TypeCodeHolder</code> object
  48. */
  49. public TypeCodeHolder(TypeCode initial) {
  50. value = initial;
  51. }
  52. /**
  53. * Reads from <code>input</code> and initalizes the value in
  54. * this <code>TypeCodeHolder</code> object
  55. * with the unmarshalled data.
  56. *
  57. * @param input the InputStream containing CDR formatted data from the wire
  58. */
  59. public void _read(InputStream input) {
  60. value = input.read_TypeCode();
  61. }
  62. /**
  63. * Marshals to <code>output</code> the value in
  64. * this <code>TypeCodeHolder</code> object.
  65. *
  66. * @param output the OutputStream which will contain the CDR formatted data
  67. */
  68. public void _write(OutputStream output) {
  69. output.write_TypeCode(value);
  70. }
  71. /**
  72. * Returns the TypeCode corresponding to the value held in
  73. * this <code>TypeCodeHolder</code> object.
  74. *
  75. * @return the TypeCode of the value held in
  76. * this <code>TypeCodeHolder</code> object
  77. */
  78. public org.omg.CORBA.TypeCode _type() {
  79. return ORB.init().get_primitive_tc(TCKind.tk_TypeCode);
  80. }
  81. }