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