DynUnionOperations.java 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* DynUnionOperations.java --
  2. Copyright (C) 2005 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package org.omg.DynamicAny;
  32. import org.omg.CORBA.TCKind;
  33. import org.omg.DynamicAny.DynAnyPackage.InvalidValue;
  34. import org.omg.DynamicAny.DynAnyPackage.TypeMismatch;
  35. /**
  36. * Defines the operations, applicable to the DynUnion. The DynUnion has only two
  37. * valid positions:
  38. * <ul>
  39. * <li>0 - contains the discriminator of the union. The discriminator defines,
  40. * which of the union variants is currently active.</li>
  41. * <li>1 - contains the currently active variant of the union content (a union
  42. * member). </li>
  43. * </ul>
  44. * The size of the union is normally 2. If the discriminator value defines no
  45. * valid variant, the union consists of discriminator only, having the size 1.
  46. *
  47. * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
  48. */
  49. public interface DynUnionOperations
  50. extends DynAnyOperations
  51. {
  52. /**
  53. * <p>Get the value of discriminator, defining which content variant
  54. * (member) is active.
  55. * </p><p>
  56. * In the current implementation, the later changes on the returned value
  57. * alter the state of the union via implemented internal listener.
  58. * </p>
  59. */
  60. DynAny get_discriminator();
  61. /**
  62. * <p>Set the value of discriminator, activating the member variant that is
  63. * consistent with the discriminator value. If the current member variant
  64. * matches the discriminator being set, it is unchanged. Otherwise, it is
  65. * replaced by the matching member variant with fields, initialised to default
  66. * values. The current position is set to 0 if the discriminator value does
  67. * not match any member variant. Otherwise, the current position is set to 1,
  68. * index of the member variant.
  69. * </p>
  70. * @throws TypeMismatch if the discriminator has a wrong type of this union.
  71. */
  72. void set_discriminator(DynAny aDiscriminator)
  73. throws TypeMismatch;
  74. /**
  75. * Get the kind of the union descriminator.
  76. *
  77. * @return the TCKind value of the discriminator typecode.
  78. */
  79. TCKind discriminator_kind();
  80. /**
  81. * Get the current variant of the union content.
  82. *
  83. * @return the current member of the union. This reference is only valid as
  84. * long as the current member does not change.
  85. *
  86. * @throws InvalidValue if the union has no active member.
  87. */
  88. DynAny member()
  89. throws InvalidValue;
  90. /**
  91. * Returns the kind of the currently active union member.
  92. *
  93. * @return the TCKind value of the union member.
  94. *
  95. * @throws InvalidValue if the union has no active member.
  96. */
  97. TCKind member_kind()
  98. throws InvalidValue;
  99. /**
  100. * Returns the name of the currently active union member.
  101. *
  102. * @return the TCKind value of the union member.
  103. *
  104. * @throws InvalidValue if the union has no active member.
  105. */
  106. String member_name()
  107. throws InvalidValue;
  108. /**
  109. * Returns true if the union has no active member. This happens if If the
  110. * discriminator value defines no valid variant. Such union consists of
  111. * discriminator only, having the size 1.
  112. */
  113. boolean has_no_active_member();
  114. /**
  115. * Set the discriminator to default value. The current position is set to 0.
  116. * This also sets the content variant to the default variant, and the size of
  117. * the union becomes 2.
  118. *
  119. * @throws TypeMismatch if the default case is not defined for this union.
  120. */
  121. void set_to_default_member()
  122. throws TypeMismatch;
  123. /**
  124. * Set the discriminator to value that does not correspond any content variant
  125. * (any union <code>case</code> label). The current position is set to 0.
  126. * The size of the union becomes 0.
  127. *
  128. * @throws TypeMismatch if the union has explicit default case.
  129. */
  130. void set_to_no_active_member()
  131. throws TypeMismatch;
  132. }