1. /*
  2. * @(#)CompositeData.java 3.19 04/02/10
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.management.openmbean;
  8. // java import
  9. //
  10. import java.io.Serializable;
  11. import java.util.Collection;
  12. import java.util.Map;
  13. // jmx import
  14. //
  15. /**
  16. * The <tt>CompositeData</tt> interface specifies the behavior of a specific type of complex <i>open data</i> objects
  17. * which represent <i>composite data</i> structures.
  18. *
  19. * @version 3.19 04/02/10
  20. * @author Sun Microsystems, Inc.
  21. *
  22. * @since 1.5
  23. * @since.unbundled JMX 1.1
  24. */
  25. public interface CompositeData {
  26. /**
  27. * Returns the <i>composite type </i> of this <i>composite data</i> instance.
  28. *
  29. * @return the type of this CompositeData.
  30. */
  31. public CompositeType getCompositeType();
  32. /**
  33. * Returns the value of the item whose name is <tt>key</tt>.
  34. *
  35. * @param key the name of the item.
  36. *
  37. * @return the value associated with this key.
  38. *
  39. * @throws IllegalArgumentException if <tt>key</tt> is a null or empty String.
  40. *
  41. * @throws InvalidKeyException if <tt>key</tt> is not an existing item name for this <tt>CompositeData</tt> instance.
  42. */
  43. public Object get(String key) ;
  44. /**
  45. * Returns an array of the values of the items whose names are specified by <tt>keys</tt>, in the same order as <tt>keys</tt>.
  46. *
  47. * @param keys the names of the items.
  48. *
  49. * @return the values corresponding to the keys.
  50. *
  51. * @throws IllegalArgumentException if an element in <tt>keys</tt> is a null or empty String.
  52. *
  53. * @throws InvalidKeyException if an element in <tt>keys</tt> is not an existing item name for this <tt>CompositeData</tt> instance.
  54. */
  55. public Object[] getAll(String[] keys) ;
  56. /**
  57. * Returns <tt>true</tt> if and only if this <tt>CompositeData</tt> instance contains
  58. * an item whose name is <tt>key</tt>.
  59. * If <tt>key</tt> is a null or empty String, this method simply returns false.
  60. *
  61. * @param key the key to be tested.
  62. *
  63. * @return true if this <tt>CompositeData</tt> contains the key.
  64. */
  65. public boolean containsKey(String key) ;
  66. /**
  67. * Returns <tt>true</tt> if and only if this <tt>CompositeData</tt> instance contains an item
  68. * whose value is <tt>value</tt>.
  69. *
  70. * @param value the value to be tested.
  71. *
  72. * @return true if this <tt>CompositeData</tt> contains the value.
  73. */
  74. public boolean containsValue(Object value) ;
  75. /**
  76. * Returns an unmodifiable Collection view of the item values contained in this <tt>CompositeData</tt> instance.
  77. * The returned collection's iterator will return the values in the ascending lexicographic order of the corresponding
  78. * item names.
  79. *
  80. * @return the values.
  81. */
  82. public Collection values() ;
  83. /**
  84. * Compares the specified <var>obj</var> parameter with this <code>CompositeData</code> instance for equality.
  85. * <p>
  86. * Returns <tt>true</tt> if and only if all of the following statements are true:
  87. * <ul>
  88. * <li><var>obj</var> is non null,</li>
  89. * <li><var>obj</var> also implements the <code>CompositeData</code> interface,</li>
  90. * <li>their composite types are equal</li>
  91. * <li>their contents (ie item values) are equal.</li>
  92. * </ul>
  93. * This ensures that this <tt>equals</tt> method works properly for <var>obj</var> parameters which are
  94. * different implementations of the <code>CompositeData</code> interface.
  95. * <br> 
  96. * @param obj the object to be compared for equality with this <code>CompositeData</code> instance;
  97. *
  98. * @return <code>true</code> if the specified object is equal to this <code>CompositeData</code> instance.
  99. */
  100. public boolean equals(Object obj) ;
  101. /**
  102. * Returns the hash code value for this <code>CompositeData</code> instance.
  103. * <p>
  104. * The hash code of a <code>CompositeData</code> instance is the sum of the hash codes
  105. * of all elements of information used in <code>equals</code> comparisons
  106. * (ie: its <i>composite type</i> and all the item values).
  107. * <p>
  108. * This ensures that <code> t1.equals(t2) </code> implies that <code> t1.hashCode()==t2.hashCode() </code>
  109. * for any two <code>CompositeData</code> instances <code>t1</code> and <code>t2</code>,
  110. * as required by the general contract of the method
  111. * {@link Object#hashCode() Object.hashCode()}.
  112. * <p>
  113. *
  114. * @return the hash code value for this <code>CompositeData</code> instance
  115. */
  116. public int hashCode() ;
  117. /**
  118. * Returns a string representation of this <code>CompositeData</code> instance.
  119. * <p>
  120. * The string representation consists of the name of the implementing class,
  121. * the string representation of the composite type of this instance, and the string representation of the contents
  122. * (ie list the itemName=itemValue mappings).
  123. *
  124. * @return a string representation of this <code>CompositeData</code> instance
  125. */
  126. public String toString() ;
  127. }