1. /*
  2. * @(#)NamedValue.java 1.19 00/02/02
  3. *
  4. * Copyright 1996-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. /**
  12. * An object used in the DII and DSI to describe
  13. * arguments and return values. <code>NamedValue</code> objects
  14. * are also used in the <code>Context</code>
  15. * object routines to pass lists of property names and values.
  16. * <P>
  17. * A <code>NamedValue</code> object contains:
  18. * <UL>
  19. * <LI>a name -- If the <code>NamedValue</code> object is used to
  20. * describe arguments to a request, the name will be an argument
  21. * identifier specified in the OMG IDL interface definition
  22. * for the operation being described.
  23. * <LI>a value -- an <code>Any</code> object
  24. * <LI>an argument mode flag -- one of the following:
  25. * <UL>
  26. * <LI><code>ARG_IN.value</code>
  27. * <LI><code>ARG_OUT.value</code>
  28. * <LI><code>ARG_INOUT.value</code>
  29. * <LI>zero -- if this <code>NamedValue</code> object represents a property
  30. * in a <code>Context</code> object rather than a parameter or
  31. * return value
  32. * </UL>
  33. * </UL>
  34. * <P>
  35. * The class <code>NamedValue</code> has three methods, which
  36. * access its fields. The following code fragment demonstrates
  37. * creating a <code>NamedValue</code> object and then accessing
  38. * its fields:
  39. * <PRE>
  40. * ORB orb = ORB.init(args, null);
  41. * String s = "argument_1";
  42. * org.omg.CORBA.Any myAny = orb.create_any();
  43. * myAny.insert_long(12345);
  44. * int in = org.omg.CORBA.ARG_IN.value;
  45. * org.omg.CORBA.NamedValue nv = orb.create_named_value(
  46. * s, myAny, in);
  47. * System.out.println("This nv name is " + nv.name());
  48. * try {
  49. * System.out.println("This nv value is " + nv.value().extract_long());
  50. * System.out.println("This nv flag is " + nv.flags());
  51. * } catch (org.omg.CORBA.BAD_OPERATION b) {
  52. * System.out.println("extract failed");
  53. * }
  54. * </PRE>
  55. *
  56. * <P>
  57. * If this code fragment were put into a <code>main</code> method,
  58. * the output would be something like the following:
  59. * <PRE>
  60. * This nv name is argument_1
  61. * This nv value is 12345
  62. * This nv flag is 1
  63. * </PRE>
  64. * <P>
  65. * Note that the method <code>value</code> returns an <code>Any</code>
  66. * object. In order to access the <code>long</code> contained in the
  67. * <code>Any</code> object,
  68. * we used the method <code>extract_long</code>.
  69. *
  70. * @see Any
  71. * @see ARG_IN
  72. * @see ARG_INOUT
  73. * @see ARG_OUT
  74. *
  75. * @version 1.12 ,09/09/97
  76. * @since JDK1.2
  77. */
  78. public abstract class NamedValue {
  79. /**
  80. * Retrieves the name for this <code>NamedValue</code> object.
  81. *
  82. * @return a <code>String</code> object representing
  83. * the name of this <code>NamedValue</code> object
  84. */
  85. public abstract String name();
  86. /**
  87. * Retrieves the value for this <code>NamedValue</code> object.
  88. *
  89. * @return an <code>Any</code> object containing
  90. * the value of this <code>NamedValue</code> object
  91. */
  92. public abstract Any value();
  93. /**
  94. * Retrieves the argument mode flag for this <code>NamedValue</code> object.
  95. *
  96. * @return an <code>int</code> representing the argument
  97. * mode for this <code>NamedValue</code> object
  98. */
  99. public abstract int flags();
  100. }