AttributeList.java :  » JMX » XMOJO » javax » management » Java Open Source

Java Open Source » JMX » XMOJO 
XMOJO » javax » management » AttributeList.java
/**
* The XMOJO Project 5
* Copyright  2003 XMOJO.org. All rights reserved.

* NO WARRANTY

* BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
* THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
* OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
* PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
* OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
* TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE
* LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
* REPAIR OR CORRECTION.

* IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL
* ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
* THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
* GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
* USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF
* DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
* PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE),
* EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGES.
**/

package javax.management;

import java.util.ArrayList;

/**
 * Represents a list of values for attributes of an MBean. The methods used
 * for the insertion of {@link javax.management.Attribute Attribute} objects
 * in the <CODE>AttributeList</CODE> overrides the corresponding methods in
 * the superclass <CODE>ArrayList</CODE>. This is needed in order to insure
 * that the objects contained in the <CODE>AttributeList</CODE> are only
 * <CODE>Attribute</CODE> objects. This avoids getting an exception when
 * retrieving elements from the <CODE>AttributeList</CODE>.
 */
public class AttributeList extends ArrayList
{
  /**
   * Constructs an empty AttributeList.
   */
  public AttributeList()
  {
    super();
  }

    /**
     * Constructs an <CODE>AttributeList</CODE> containing the elements of the
   * <CODE>AttributeList</CODE> specified, in the order in which they are
   * returned by the <CODE>AttributeList</CODE>'s iterator.
   * The <CODE>AttributeList</CODE> instance has an initial capacity of
   * 110% of the size of the <CODE>AttributeList</CODE> specified.
     */
  public AttributeList(AttributeList list)
  {
    super(list);
  }

  /**
   * Constructs an empty AttributeList with the initial capacity specified.
   *
   * @param initialCapacity Empty AttributeList is constructed with
   *         the mentioned initial capacity
   */
  public AttributeList(int initialCapacity)
  {
    super(initialCapacity);
  }

    /**
     * Adds the <CODE>Attribute</CODE> specified as the last element of the list.
     *
     * @param object  The attribute to be added.
     */
  public void add(Attribute object)
  {
    super.add(object);
  }

  /**
   * Inserts the attribute specified as an element at the position specified.
   * Elements with an index greater than or equal to the current position are
   * shifted up. If the index is out of range (index < 0 || index > size()
   * a RuntimeOperationsException should be raised, wrapping the
     * java.lang.IndexOutOfBoundsException thrown.
     *
     * @param index The position in the list where the new Attribute object is
   *         to be inserted.
   *
   * @param object The Attribute object to be inserted.
   */
  public void add(int index, Attribute object)
  {
    try
    {
      super.add(index, object);
    }
    catch(IndexOutOfBoundsException e)
    {
      throw new RuntimeOperationsException(e);
    }
  }

    /**
     * Appends all the elements in the <CODE>AttributeList</CODE> specified to the end
     * of the list, in the order in which they are returned by the Iterator of
     * the <CODE>AttributeList</CODE> specified.
     *
     * @param list  Elements to be inserted into the list.
     */
  public boolean addAll(AttributeList list)
  {
    try
    {
      return super.addAll(list);
    }
    catch(IndexOutOfBoundsException e)
    {
      throw new RuntimeOperationsException(e);
    }
  }

    /**
     * Inserts all of the elements in the <CODE>AttributeList</CODE> specified
   * into this list, starting at the specified position, in the order in
   * which they are returned by the Iterator of the <CODE>AttributeList</CODE>
   * specified. If the index is out of range (index < 0 || index > size() a
   * RuntimeOperationsException should be raised, wrapping
   * the java.lang.IndexOutOfBoundsException thrown.
     *
     * @param list  Elements to be inserted into the list.
     *
     * @param index  Position at which to insert the first element from the
   *         <CODE>AttributeList</CODE> specified.
     */
  public boolean addAll(int index, AttributeList list)
  {
    try
    {
      return(super.addAll(index, list));
    }
    catch(IndexOutOfBoundsException e)
    {
        throw (new RuntimeOperationsException(e,
                  "The specified index is out of range"));
    }
  }

    /**
     * Sets the element at the position specified to be the attribute specified.
   * The previous element at that position is discarded. If the index is out
   * of range (index < 0 || index > size() a RuntimeOperationsException should
     * be raised, wrapping the java.lang.IndexOutOfBoundsException thrown.
     *
     * @param object  The value to which the attribute element should be set.
     *
     * @param index  The position specified.
     */
  public void set(int index, Attribute object)
  {
    try
    {
      super.set(index, object);
    }
    catch(IndexOutOfBoundsException e)
    {
        throw (new RuntimeOperationsException(e,
                  "The specified index is out of range"));
    }
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.