< prev index next >
src/java.management/share/classes/javax/management/openmbean/CompositeDataSupport.java
Print this page
*** 43,54 ****
import java.util.TreeSet;
//
/**
! * The <tt>CompositeDataSupport</tt> class is the <i>open data</i> class which
! * implements the <tt>CompositeData</tt> interface.
*
*
* @since 1.5
*/
public class CompositeDataSupport
--- 43,54 ----
import java.util.TreeSet;
//
/**
! * The {@code CompositeDataSupport} class is the <i>open data</i> class which
! * implements the {@code CompositeData} interface.
*
*
* @since 1.5
*/
public class CompositeDataSupport
*** 68,118 ****
* @serial The <i>composite type </i> of this <i>composite data</i> instance.
*/
private final CompositeType compositeType;
/**
! * <p>Constructs a <tt>CompositeDataSupport</tt> instance with the specified
! * <tt>compositeType</tt>, whose item values
! * are specified by <tt>itemValues[]</tt>, in the same order as in
! * <tt>itemNames[]</tt>.
! * As a <tt>CompositeType</tt> does not specify any order on its items,
! * the <tt>itemNames[]</tt> parameter is used
! * to specify the order in which the values are given in <tt>itemValues[]</tt>.
! * The items contained in this <tt>CompositeDataSupport</tt> instance are
! * internally stored in a <tt>TreeMap</tt>,
* thus sorted in ascending lexicographic order of their names, for faster
* retrieval of individual item values.</p>
*
* <p>The constructor checks that all the constraints listed below for each
* parameter are satisfied,
* and throws the appropriate exception if they are not.</p>
*
* @param compositeType the <i>composite type </i> of this <i>composite
* data</i> instance; must not be null.
*
! * @param itemNames <tt>itemNames</tt> must list, in any order, all the
! * item names defined in <tt>compositeType</tt>; the order in which the
! * names are listed, is used to match values in <tt>itemValues[]</tt>; must
* not be null or empty.
*
* @param itemValues the values of the items, listed in the same order as
! * their respective names in <tt>itemNames</tt>; each item value can be
* null, but if it is non-null it must be a valid value for the open type
! * defined in <tt>compositeType</tt> for the corresponding item; must be of
! * the same size as <tt>itemNames</tt>; must not be null or empty.
*
! * @throws IllegalArgumentException <tt>compositeType</tt> is null, or
! * <tt>itemNames[]</tt> or <tt>itemValues[]</tt> is null or empty, or one
! * of the elements in <tt>itemNames[]</tt> is a null or empty string, or
! * <tt>itemNames[]</tt> and <tt>itemValues[]</tt> are not of the same size.
! *
! * @throws OpenDataException <tt>itemNames[]</tt> or
! * <tt>itemValues[]</tt>'s size differs from the number of items defined in
! * <tt>compositeType</tt>, or one of the elements in <tt>itemNames[]</tt>
! * does not exist as an item name defined in <tt>compositeType</tt>, or one
! * of the elements in <tt>itemValues[]</tt> is not a valid value for the
! * corresponding item as defined in <tt>compositeType</tt>.
*/
public CompositeDataSupport(
CompositeType compositeType, String[] itemNames, Object[] itemValues)
throws OpenDataException {
this(makeMap(itemNames, itemValues), compositeType);
--- 68,118 ----
* @serial The <i>composite type </i> of this <i>composite data</i> instance.
*/
private final CompositeType compositeType;
/**
! * <p>Constructs a {@code CompositeDataSupport} instance with the specified
! * {@code compositeType}, whose item values
! * are specified by {@code itemValues[]}, in the same order as in
! * {@code itemNames[]}.
! * As a {@code CompositeType} does not specify any order on its items,
! * the {@code itemNames[]} parameter is used
! * to specify the order in which the values are given in {@code itemValues[]}.
! * The items contained in this {@code CompositeDataSupport} instance are
! * internally stored in a {@code TreeMap},
* thus sorted in ascending lexicographic order of their names, for faster
* retrieval of individual item values.</p>
*
* <p>The constructor checks that all the constraints listed below for each
* parameter are satisfied,
* and throws the appropriate exception if they are not.</p>
*
* @param compositeType the <i>composite type </i> of this <i>composite
* data</i> instance; must not be null.
*
! * @param itemNames {@code itemNames} must list, in any order, all the
! * item names defined in {@code compositeType}; the order in which the
! * names are listed, is used to match values in {@code itemValues[]}; must
* not be null or empty.
*
* @param itemValues the values of the items, listed in the same order as
! * their respective names in {@code itemNames}; each item value can be
* null, but if it is non-null it must be a valid value for the open type
! * defined in {@code compositeType} for the corresponding item; must be of
! * the same size as {@code itemNames}; must not be null or empty.
*
! * @throws IllegalArgumentException {@code compositeType} is null, or
! * {@code itemNames[]} or {@code itemValues[]} is null or empty, or one
! * of the elements in {@code itemNames[]} is a null or empty string, or
! * {@code itemNames[]} and {@code itemValues[]} are not of the same size.
! *
! * @throws OpenDataException {@code itemNames[]} or
! * {@code itemValues[]}'s size differs from the number of items defined in
! * {@code compositeType}, or one of the elements in {@code itemNames[]}
! * does not exist as an item name defined in {@code compositeType}, or one
! * of the elements in {@code itemValues[]} is not a valid value for the
! * corresponding item as defined in {@code compositeType}.
*/
public CompositeDataSupport(
CompositeType compositeType, String[] itemNames, Object[] itemValues)
throws OpenDataException {
this(makeMap(itemNames, itemValues), compositeType);
*** 145,176 ****
return map;
}
/**
* <p>
! * Constructs a <tt>CompositeDataSupport</tt> instance with the specified <tt>compositeType</tt>, whose item names and corresponding values
! * are given by the mappings in the map <tt>items</tt>.
* This constructor converts the keys to a string array and the values to an object array and calls
! * <tt>CompositeDataSupport(javax.management.openmbean.CompositeType, java.lang.String[], java.lang.Object[])</tt>.
*
* @param compositeType the <i>composite type </i> of this <i>composite data</i> instance;
* must not be null.
* @param items the mappings of all the item names to their values;
! * <tt>items</tt> must contain all the item names defined in <tt>compositeType</tt>;
* must not be null or empty.
*
! * @throws IllegalArgumentException <tt>compositeType</tt> is null, or
! * <tt>items</tt> is null or empty, or one of the keys in <tt>items</tt> is a null
* or empty string.
! * @throws OpenDataException <tt>items</tt>' size differs from the
! * number of items defined in <tt>compositeType</tt>, or one of the
! * keys in <tt>items</tt> does not exist as an item name defined in
! * <tt>compositeType</tt>, or one of the values in <tt>items</tt>
* is not a valid value for the corresponding item as defined in
! * <tt>compositeType</tt>.
! * @throws ArrayStoreException one or more keys in <tt>items</tt> is not of
! * the class <tt>java.lang.String</tt>.
*/
public CompositeDataSupport(CompositeType compositeType,
Map<String,?> items)
throws OpenDataException {
this(makeMap(items), compositeType);
--- 145,177 ----
return map;
}
/**
* <p>
! * Constructs a {@code CompositeDataSupport} instance with the specified {@code compositeType},
! * whose item names and corresponding values
! * are given by the mappings in the map {@code items}.
* This constructor converts the keys to a string array and the values to an object array and calls
! * {@code CompositeDataSupport(javax.management.openmbean.CompositeType, java.lang.String[], java.lang.Object[])}.
*
* @param compositeType the <i>composite type </i> of this <i>composite data</i> instance;
* must not be null.
* @param items the mappings of all the item names to their values;
! * {@code items} must contain all the item names defined in {@code compositeType};
* must not be null or empty.
*
! * @throws IllegalArgumentException {@code compositeType} is null, or
! * {@code items} is null or empty, or one of the keys in {@code items} is a null
* or empty string.
! * @throws OpenDataException {@code items}' size differs from the
! * number of items defined in {@code compositeType}, or one of the
! * keys in {@code items} does not exist as an item name defined in
! * {@code compositeType}, or one of the values in {@code items}
* is not a valid value for the corresponding item as defined in
! * {@code compositeType}.
! * @throws ArrayStoreException one or more keys in {@code items} is not of
! * the class {@code java.lang.String}.
*/
public CompositeDataSupport(CompositeType compositeType,
Map<String,?> items)
throws OpenDataException {
this(makeMap(items), compositeType);
*** 251,266 ****
return compositeType;
}
/**
! * Returns the value of the item whose name is <tt>key</tt>.
*
! * @throws IllegalArgumentException if <tt>key</tt> is a null or empty String.
*
! * @throws InvalidKeyException if <tt>key</tt> is not an existing item name for
! * this <tt>CompositeData</tt> instance.
*/
public Object get(String key) {
if ( (key == null) || (key.trim().equals("")) ) {
throw new IllegalArgumentException("Argument key cannot be a null or empty String.");
--- 252,267 ----
return compositeType;
}
/**
! * Returns the value of the item whose name is {@code key}.
*
! * @throws IllegalArgumentException if {@code key} is a null or empty String.
*
! * @throws InvalidKeyException if {@code key} is not an existing item name for
! * this {@code CompositeData} instance.
*/
public Object get(String key) {
if ( (key == null) || (key.trim().equals("")) ) {
throw new IllegalArgumentException("Argument key cannot be a null or empty String.");
*** 271,287 ****
return contents.get(key.trim());
}
/**
* 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>.
*
! * @throws IllegalArgumentException if an element in <tt>keys</tt> is a null
* or empty String.
*
! * @throws InvalidKeyException if an element in <tt>keys</tt> is not an existing
! * item name for this <tt>CompositeData</tt> instance.
*/
public Object[] getAll(String[] keys) {
if ( (keys == null) || (keys.length == 0) ) {
return new Object[0];
--- 272,288 ----
return contents.get(key.trim());
}
/**
* Returns an array of the values of the items whose names are specified by
! * {@code keys}, in the same order as {@code keys}.
*
! * @throws IllegalArgumentException if an element in {@code keys} is a null
* or empty String.
*
! * @throws InvalidKeyException if an element in {@code keys} is not an existing
! * item name for this {@code CompositeData} instance.
*/
public Object[] getAll(String[] keys) {
if ( (keys == null) || (keys.length == 0) ) {
return new Object[0];
*** 292,326 ****
}
return results;
}
/**
! * Returns <tt>true</tt> if and only if this <tt>CompositeData</tt> instance contains
! * an item whose name is <tt>key</tt>.
! * If <tt>key</tt> is a null or empty String, this method simply returns false.
*/
public boolean containsKey(String key) {
if ( (key == null) || (key.trim().equals("")) ) {
return false;
}
return contents.containsKey(key);
}
/**
! * Returns <tt>true</tt> if and only if this <tt>CompositeData</tt> instance
* contains an item
! * whose value is <tt>value</tt>.
*/
public boolean containsValue(Object value) {
return contents.containsValue(value);
}
/**
* Returns an unmodifiable Collection view of the item values contained in this
! * <tt>CompositeData</tt> instance.
* The returned collection's iterator will return the values in the ascending
* lexicographic order of the corresponding
* item names.
*/
public Collection<?> values() {
--- 293,327 ----
}
return results;
}
/**
! * Returns {@code true} if and only if this {@code CompositeData} instance contains
! * an item whose name is {@code key}.
! * If {@code key} is a null or empty String, this method simply returns false.
*/
public boolean containsKey(String key) {
if ( (key == null) || (key.trim().equals("")) ) {
return false;
}
return contents.containsKey(key);
}
/**
! * Returns {@code true} if and only if this {@code CompositeData} instance
* contains an item
! * whose value is {@code value}.
*/
public boolean containsValue(Object value) {
return contents.containsValue(value);
}
/**
* Returns an unmodifiable Collection view of the item values contained in this
! * {@code CompositeData} instance.
* The returned collection's iterator will return the values in the ascending
* lexicographic order of the corresponding
* item names.
*/
public Collection<?> values() {
*** 330,340 ****
/**
* Compares the specified <var>obj</var> parameter with this
* <code>CompositeDataSupport</code> instance for equality.
* <p>
! * Returns <tt>true</tt> if and only if all of the following statements are true:
* <ul>
* <li><var>obj</var> is non null,</li>
* <li><var>obj</var> also implements the <code>CompositeData</code> interface,</li>
* <li>their composite types are equal</li>
* <li>their contents, i.e. (name, value) pairs are equal. If a value contained in
--- 331,341 ----
/**
* Compares the specified <var>obj</var> parameter with this
* <code>CompositeDataSupport</code> instance for equality.
* <p>
! * Returns {@code true} if and only if all of the following statements are true:
* <ul>
* <li><var>obj</var> is non null,</li>
* <li><var>obj</var> also implements the <code>CompositeData</code> interface,</li>
* <li>their composite types are equal</li>
* <li>their contents, i.e. (name, value) pairs are equal. If a value contained in
*** 342,356 ****
* the {@link java.util.Arrays#deepEquals(Object[], Object[]) deepEquals} method
* for arrays of object reference types or the appropriate overloading of
* {@code Arrays.equals(e1,e2)} for arrays of primitive types</li>
* </ul>
* <p>
! * This ensures that this <tt>equals</tt> method works properly for
* <var>obj</var> parameters which are different implementations of the
* <code>CompositeData</code> interface, with the restrictions mentioned in the
* {@link java.util.Collection#equals(Object) equals}
! * method of the <tt>java.util.Collection</tt> interface.
*
* @param obj the object to be compared for equality with this
* <code>CompositeDataSupport</code> instance.
* @return <code>true</code> if the specified object is equal to this
* <code>CompositeDataSupport</code> instance.
--- 343,357 ----
* the {@link java.util.Arrays#deepEquals(Object[], Object[]) deepEquals} method
* for arrays of object reference types or the appropriate overloading of
* {@code Arrays.equals(e1,e2)} for arrays of primitive types</li>
* </ul>
* <p>
! * This ensures that this {@code equals} method works properly for
* <var>obj</var> parameters which are different implementations of the
* <code>CompositeData</code> interface, with the restrictions mentioned in the
* {@link java.util.Collection#equals(Object) equals}
! * method of the {@code java.util.Collection} interface.
*
* @param obj the object to be compared for equality with this
* <code>CompositeDataSupport</code> instance.
* @return <code>true</code> if the specified object is equal to this
* <code>CompositeDataSupport</code> instance.
< prev index next >