FileDocCategorySizeDatePackage
AttributeList.javaAPI DocJava SE 6 API10869Tue Jun 10 00:26:12 BST 2008javax.management

AttributeList

public class AttributeList extends 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 AttributeList overrides the corresponding methods in the superclass ArrayList. This is needed in order to insure that the objects contained in the AttributeList are only Attribute objects. This avoids getting an exception when retrieving elements from the AttributeList.
since
1.5

Fields Summary
private transient boolean
typeSafe
private transient boolean
tainted
private static final long
serialVersionUID
Constructors Summary
public AttributeList()
Constructs an empty AttributeList.


             
      
	super();
    
public AttributeList(int initialCapacity)
Constructs an empty AttributeList with the initial capacity specified.

param
initialCapacity the initial capacity of the AttributeList, as specified by {@link ArrayList#ArrayList(int)}.

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

param
list the AttributeList that defines the initial contents of the new AttributeList.
see
ArrayList#ArrayList(java.util.Collection)

	super(list);
    
public AttributeList(List list)
Constructs an {@code AttributeList} containing the elements of the {@code List} specified, in the order in which they are returned by the {@code List}'s iterator.

param
list the {@code List} that defines the initial contents of the new {@code AttributeList}.
exception
IllegalArgumentException if the {@code list} parameter is {@code null} or if the {@code list} parameter contains any non-Attribute objects.
see
ArrayList#ArrayList(java.util.Collection)
since
1.6

        // Check for null parameter
        //
        if (list == null)
            throw new IllegalArgumentException("Null parameter");

        // Check for non-Attribute objects
        //
        checkTypeSafe(list);

        // Build the List<Attribute>
        //
        super.addAll(list);
    
Methods Summary
public booleanadd(java.lang.Object o)

        if (!tainted)
            tainted = isTainted(o);
        if (typeSafe)
            checkTypeSafe(o);
        return super.add(o);
    
public voidadd(int index, java.lang.Object element)

        if (!tainted)
            tainted = isTainted(element);
        if (typeSafe)
            checkTypeSafe(element);
        super.add(index, element);
    
public voidadd(javax.management.Attribute object)
Adds the {@code Attribute} specified as the last element of the list.

param
object The attribute to be added.

	super.add(object);
    
public voidadd(int index, javax.management.Attribute 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
object The Attribute object to be inserted.
param
index The position in the list where the new {@code Attribute} object is to be inserted.

	try {
	    super.add(index, object);
	}
	catch (IndexOutOfBoundsException e) {
	    throw new RuntimeOperationsException(e,
                "The specified index is out of range");
	}
    
public booleanaddAll(int index, javax.management.AttributeList list)
Inserts all of the elements in the AttributeList specified into this list, starting at the specified position, in the order in which they are returned by the Iterator of the {@code AttributeList} 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 AttributeList specified.
return
true if this list changed as a result of the call.
see
ArrayList#addAll(int, java.util.Collection)

	try {
	    return super.addAll(index, list);
	}
	catch (IndexOutOfBoundsException e) {
	    throw new RuntimeOperationsException(e,
                "The specified index is out of range");
	}
    
public booleanaddAll(java.util.Collection c)

        if (!tainted)
            tainted = isTainted(c);
        if (typeSafe)
            checkTypeSafe(c);
        return super.addAll(c);
    
public booleanaddAll(int index, java.util.Collection c)

        if (!tainted)
            tainted = isTainted(c);
        if (typeSafe)
            checkTypeSafe(c);
        return super.addAll(index, c);
    
public booleanaddAll(javax.management.AttributeList list)
Appends all the elements in the AttributeList specified to the end of the list, in the order in which they are returned by the Iterator of the AttributeList specified.

param
list Elements to be inserted into the list.
return
true if this list changed as a result of the call.
see
ArrayList#addAll(java.util.Collection)

	return (super.addAll(list));
    
public java.util.ListasList()
Return a view of this list as a {@code List}. Changes to the returned value are reflected by changes to the original {@code AttributeList} and vice versa.

return
a {@code List} whose contents reflect the contents of this {@code AttributeList}.

If this method has ever been called on a given {@code AttributeList} instance, a subsequent attempt to add an object to that instance which is not an {@code Attribute} will fail with a {@code IllegalArgumentException}. For compatibility reasons, an {@code AttributeList} on which this method has never been called does allow objects other than {@code Attribute}s to be added.

throws
IllegalArgumentException if this {@code AttributeList} contains an element that is not an {@code Attribute}.
since
1.6

        if (!typeSafe) {
            if (tainted)
                checkTypeSafe(this);
            typeSafe = true;
        }
	return (List<Attribute>) (List) this;
    
private static voidcheckTypeSafe(java.lang.Object o)
IllegalArgumentException if o is a non-Attribute object.

        try {
            o = (Attribute) o;
        } catch (ClassCastException e) {
            throw new IllegalArgumentException(e);
        }
    
private static voidcheckTypeSafe(java.util.Collection c)
IllegalArgumentException if c contains any non-Attribute objects.

        try {
            Attribute a;
            for (Object o : c)
                a = (Attribute) o;
        } catch (ClassCastException e) {
            throw new IllegalArgumentException(e);
        }
    
private static booleanisTainted(java.lang.Object o)
Returns true if o is a non-Attribute object.

        try {
            checkTypeSafe(o);
        } catch (IllegalArgumentException e) {
            return true;
        }
        return false;
    
private static booleanisTainted(java.util.Collection c)
Returns true if c contains any non-Attribute objects.

        try {
            checkTypeSafe(c);
        } catch (IllegalArgumentException e) {
            return true;
        }
        return false;
    
public java.lang.Objectset(int index, java.lang.Object element)

        if (!tainted)
            tainted = isTainted(element);
        if (typeSafe)
            checkTypeSafe(element);
        return super.set(index, element);
    
public voidset(int index, javax.management.Attribute object)
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.

	try {
	    super.set(index, object);
	}
	catch (IndexOutOfBoundsException e) {
	    throw new RuntimeOperationsException(e,
                "The specified index is out of range");
	}