001: /* JFox, the OpenSource J2EE Application Server
002: *
003: * Copyright (C) 2002 huihoo.org
004: * Distributable under GNU LGPL license
005: * See the GNU Lesser General Public License for more details.
006: */
007:
008: package javax.management.openmbean;
009:
010: import java.util.Collection;
011:
012: /**
013: *
014: * @author <a href="mailto:young_yy@hotmail.org">Young Yang</a>
015: */
016:
017: public interface CompositeData {
018:
019: /**
020: * Returns the <i>composite type </i> of this <i>composite data</i> instance.
021: *
022: * @return the type of this CompositeData.
023: */
024: public CompositeType getCompositeType();
025:
026: /**
027: * Returns the value of the item whose name is <tt>key</tt>.
028: *
029: * @param key the name of the item.
030: *
031: * @return the value associated with this key.
032: *
033: * @throws IllegalArgumentException if <tt>key</tt> is a null or empty String.
034: *
035: * @throws InvalidKeyException if <tt>key</tt> is not an existing item name for this <tt>CompositeData</tt> instance.
036: */
037: public Object get(String key);
038:
039: /**
040: * 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>.
041: *
042: * @param keys the names of the items.
043: *
044: * @return the values corresponding to the keys.
045: *
046: * @throws IllegalArgumentException if an element in <tt>keys</tt> is a null or empty String.
047: *
048: * @throws InvalidKeyException if an element in <tt>keys</tt> is not an existing item name for this <tt>CompositeData</tt> instance.
049: */
050: public Object[] getAll(String[] keys);
051:
052: /**
053: * Returns <tt>true</tt> if and only if this <tt>CompositeData</tt> instance contains
054: * an item whose name is <tt>key</tt>.
055: * If <tt>key</tt> is a null or empty String, this method simply returns false.
056: *
057: * @param key the key to be tested.
058: *
059: * @return true if this <tt>CompositeData</tt> contains the key.
060: */
061: public boolean containsKey(String key);
062:
063: /**
064: * Returns <tt>true</tt> if and only if this <tt>CompositeData</tt> instance contains an item
065: * whose value is <tt>value</tt>.
066: *
067: * @param value the value to be tested.
068: *
069: * @return true if this <tt>CompositeData</tt> contains the value.
070: */
071: public boolean containsValue(Object value);
072:
073: /**
074: * Returns an unmodifiable Collection view of the item values contained in this <tt>CompositeData</tt> instance.
075: * The returned collection's iterator will return the values in the ascending lexicographic order of the corresponding
076: * item names.
077: *
078: * @return the values.
079: */
080: public Collection values();
081:
082: /**
083: * Compares the specified <var>obj</var> parameter with this <code>CompositeData</code> instance for equality.
084: * <p>
085: * Returns <tt>true</tt> if and only if all of the following statements are true:
086: * <ul>
087: * <li><var>obj</var> is non null,</li>
088: * <li><var>obj</var> also implements the <code>CompositeData</code> interface,</li>
089: * <li>their composite types are equal</li>
090: * <li>their contents (ie item values) are equal.</li>
091: * </ul>
092: * This ensures that this <tt>equals</tt> method works properly for <var>obj</var> parameters which are
093: * different implementations of the <code>CompositeData</code> interface.
094: * <br>
095: * @param obj the object to be compared for equality with this <code>CompositeData</code> instance;
096: *
097: * @return <code>true</code> if the specified object is equal to this <code>CompositeData</code> instance.
098: */
099: public boolean equals(Object obj);
100:
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 <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/Object.html#hashCode()">
112: * <code>Object.hashCode</code> </a>}.
113: * <p>
114: *
115: * @return the hash code value for this <code>CompositeData</code> instance
116: */
117: public int hashCode();
118:
119: /**
120: * Returns a string representation of this <code>CompositeData</code> instance.
121: * <p>
122: * The string representation consists of the name of the implementing class,
123: * the string representation of the composite type of this instance, and the string representation of the contents
124: * (ie list the itemName=itemValue mappings).
125: *
126: * @return a string representation of this <code>CompositeData</code> instance
127: */
128: public String toString();
129:
130: }
|