KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > management > AttributeList


1 /*
2  * @(#)AttributeList.java 1.25 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.management;
9
10
11 // java import
12
import java.util.ArrayList JavaDoc;
13
14
15 /**
16  * Represents a list of values for attributes of an
17  * MBean. The methods used for the insertion of {@link javax.management.Attribute Attribute} objects in
18  * the <CODE>AttributeList</CODE> overrides the corresponding methods in the superclass
19  * <CODE>ArrayList</CODE>. This is needed in order to insure that the objects contained
20  * in the <CODE>AttributeList</CODE> are only <CODE>Attribute</CODE> objects. This avoids getting
21  * an exception when retrieving elements from the <CODE>AttributeList</CODE>.
22  *
23  * @since 1.5
24  */

25 public class AttributeList extends ArrayList JavaDoc {
26     
27
28     /* Serial version */
29     private static final long serialVersionUID = -4077085769279709076L;
30
31     /**
32      * Constructs an empty <CODE>AttributeList</CODE>.
33      */

34     public AttributeList() {
35     super();
36     }
37     
38     /**
39      * Constructs an empty <CODE>AttributeList</CODE> with the initial capacity specified.
40      *
41      * @param initialCapacity the initial capacity of the
42      * <code>AttributeList</code>, as specified by {@link
43      * ArrayList#ArrayList(int)}.
44      */

45     public AttributeList(int initialCapacity) {
46     super(initialCapacity);
47     }
48     
49     /**
50      * Constructs an <CODE>AttributeList</CODE> containing the elements of the <CODE>AttributeList</CODE> specified,
51      * in the order in which they are returned by the <CODE>AttributeList</CODE>'s iterator.
52      * The <CODE>AttributeList</CODE> instance has an initial capacity of 110% of the
53      * size of the <CODE>AttributeList</CODE> specified.
54      *
55      * @param list the <code>AttributeList</code> that defines the initial
56      * contents of the new <code>AttributeList</code>.
57      *
58      * @see ArrayList#ArrayList(java.util.Collection)
59      */

60     public AttributeList(AttributeList JavaDoc list) {
61     super(list);
62     }
63     
64     
65     /**
66      * Adds the <CODE>Attribute</CODE> specified as the last element of the list.
67      *
68      *@param object The attribute to be added.
69      */

70     public void add(Attribute JavaDoc object) {
71     super.add(object);
72     }
73     
74     /**
75      * Inserts the attribute specified as an element at the position specified.
76      * Elements with an index greater than or equal to the current position are
77      * shifted up. If the index is out of range (index < 0 || index >
78      * size() a RuntimeOperationsException should be raised, wrapping the
79      * java.lang.IndexOutOfBoundsException thrown.
80      *
81      * @param object The <CODE>Attribute</CODE> object to be inserted.
82      * @param index The position in the list where the new <CODE>Attribute</CODE> object is to be
83      * inserted.
84      */

85     public void add(int index, Attribute JavaDoc object) {
86     try {
87         super.add(index, object);
88     }
89     catch (IndexOutOfBoundsException JavaDoc e) {
90         throw (new RuntimeOperationsException JavaDoc(e, "The specified index is out of range"));
91     }
92     }
93     
94     /**
95      * Sets the element at the position specified to be the attribute specified.
96      * The previous element at that position is discarded. If the index is
97      * out of range (index < 0 || index > size() a RuntimeOperationsException should
98      * be raised, wrapping the java.lang.IndexOutOfBoundsException thrown.
99      *
100      * @param object The value to which the attribute element should be set.
101      * @param index The position specified.
102      */

103     public void set(int index, Attribute JavaDoc object) {
104     try {
105         super.set(index, object);
106     }
107     catch (IndexOutOfBoundsException JavaDoc e) {
108         throw (new RuntimeOperationsException JavaDoc(e, "The specified index is out of range"));
109     }
110     }
111     
112     /**
113      * Appends all the elements in the <CODE>AttributeList</CODE> specified to the end
114      * of the list, in the order in which they are returned by the Iterator of
115      * the <CODE>AttributeList</CODE> specified.
116      *
117      * @param list Elements to be inserted into the list.
118      *
119      * @return true if this list changed as a result of the call.
120      *
121      * @see ArrayList#addAll(java.util.Collection)
122      */

123     public boolean addAll(AttributeList JavaDoc list) {
124     return (super.addAll(list));
125     }
126     
127     /**
128      * Inserts all of the elements in the <CODE>AttributeList</CODE> specified into this
129      * list, starting at the specified position, in the order in which they
130      * are returned by the Iterator of the <CODE>AttributeList</CODE> specified. If
131      * the index is out of range (index < 0 || index > size() a RuntimeOperationsException should
132      * be raised, wrapping the java.lang.IndexOutOfBoundsException thrown.
133      *
134      * @param list Elements to be inserted into the list.
135      * @param index Position at which to insert the first element from the <CODE>AttributeList</CODE> specified.
136      *
137      * @return true if this list changed as a result of the call.
138      *
139      * @see ArrayList#addAll(int, java.util.Collection)
140      */

141     public boolean addAll(int index, AttributeList JavaDoc list) {
142     try {
143         return(super.addAll(index, list));
144     }
145     catch (IndexOutOfBoundsException JavaDoc e) {
146         throw (new RuntimeOperationsException JavaDoc(e, "The specified index is out of range"));
147     }
148     }
149     
150 }
151
Popular Tags