KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > management > relation > RoleUnresolvedList


1 /*
2  * @(#)RoleUnresolvedList.java 1.21 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.relation;
9
10 import java.util.ArrayList JavaDoc;
11 import java.util.List JavaDoc;
12 import java.util.Iterator JavaDoc;
13
14 /**
15  * A RoleUnresolvedList represents a list of RoleUnresolved objects,
16  * representing roles not retrieved from a relation due to a problem
17  * encountered when trying to access (read or write to roles).
18  *
19  * @since 1.5
20  */

21 public class RoleUnresolvedList extends ArrayList JavaDoc {
22
23     /* Serial version */
24     private static final long serialVersionUID = 4054902803091433324L;
25
26     //
27
// Constructors
28
//
29

30     /**
31      * Constructs an empty RoleUnresolvedList.
32      */

33     public RoleUnresolvedList() {
34     super();
35     return;
36     }
37
38     /**
39      * Constructs an empty RoleUnresolvedList with the initial capacity
40      * specified.
41      *
42      * @param theInitialCapacity initial capacity
43      */

44     public RoleUnresolvedList(int theInitialCapacity) {
45     super(theInitialCapacity);
46     return;
47     }
48
49     /**
50      * Constructs a RoleUnresolvedList containing the elements of the
51      * List specified, in the order in which they are returned
52      * by the List's iterator. The RoleUnresolvedList instance has
53      * an initial capacity of 110% of the size of the List
54      * specified.
55      *
56      * @param theList list of RoleUnresolved objects
57      *
58      * @exception IllegalArgumentException if:
59      * <P>- null parameter
60      * <P>or
61      * <P>- an element in the List is not a RoleUnresolved
62      */

63     public RoleUnresolvedList(List JavaDoc theList)
64     throws IllegalArgumentException JavaDoc {
65
66     if (theList == null) {
67         String JavaDoc excMsg = "Invalid parameter";
68         throw new IllegalArgumentException JavaDoc(excMsg);
69     }
70
71     int i = 0;
72     for (Iterator JavaDoc eltIter = theList.iterator();
73          eltIter.hasNext();) {
74         Object JavaDoc currElt = eltIter.next();
75         if (!(currElt instanceof RoleUnresolved JavaDoc)) {
76         StringBuffer JavaDoc excMsgStrB = new StringBuffer JavaDoc();
77         String JavaDoc excMsg = "An element is not a RoleUnresolved at index ";
78         excMsgStrB.append(excMsg);
79         excMsgStrB.append(i);
80         throw new IllegalArgumentException JavaDoc(excMsgStrB.toString());
81         }
82         i++;
83         super.add(currElt);
84     }
85     return;
86     }
87
88     //
89
// Accessors
90
//
91

92     /**
93      * Adds the RoleUnresolved specified as the last element of the list.
94      *
95      * @param theRoleUnres - the unresolved role to be added.
96      *
97      * @exception IllegalArgumentException if the unresolved role is null.
98      */

99     public void add(RoleUnresolved JavaDoc theRoleUnres)
100     throws IllegalArgumentException JavaDoc {
101
102     if (theRoleUnres == null) {
103         String JavaDoc excMsg = "Invalid parameter";
104         throw new IllegalArgumentException JavaDoc(excMsg);
105     }
106     super.add(theRoleUnres);
107     return;
108     }
109
110     /**
111      * Inserts the unresolved role specified as an element at the position
112      * specified.
113      * Elements with an index greater than or equal to the current position are
114      * shifted up.
115      *
116      * @param index - The position in the list where the new
117      * RoleUnresolved object is to be inserted.
118      * @param theRoleUnres - The RoleUnresolved object to be inserted.
119      *
120      * @exception IllegalArgumentException if the unresolved role is null.
121      * @exception IndexOutOfBoundsException if index is out of range
122      * (<code>index &lt; 0 || index &gt; size()</code>).
123      */

124     public void add(int index,
125             RoleUnresolved JavaDoc theRoleUnres)
126     throws IllegalArgumentException JavaDoc,
127            IndexOutOfBoundsException JavaDoc {
128
129     if (theRoleUnres == null) {
130         String JavaDoc excMsg = "Invalid parameter";
131         throw new IllegalArgumentException JavaDoc(excMsg);
132     }
133
134     super.add(index, theRoleUnres);
135     return;
136     }
137
138     /**
139      * Sets the element at the position specified to be the unresolved role
140      * specified.
141      * The previous element at that position is discarded.
142      *
143      * @param index - The position specified.
144      * @param theRoleUnres - The value to which the unresolved role element
145      * should be set.
146      *
147      * @exception IllegalArgumentException if the unresolved role is null.
148      * @exception IndexOutOfBoundsException if index is out of range
149      * (<code>index &lt; 0 || index &gt;= size()</code>).
150      */

151      public void set(int index,
152              RoleUnresolved JavaDoc theRoleUnres)
153      throws IllegalArgumentException JavaDoc,
154                 IndexOutOfBoundsException JavaDoc {
155
156     if (theRoleUnres == null) {
157         String JavaDoc excMsg = "Invalid parameter";
158         throw new IllegalArgumentException JavaDoc(excMsg);
159     }
160
161     super.set(index, theRoleUnres);
162     return;
163      }
164
165     /**
166      * Appends all the elements in the RoleUnresolvedList specified to the end
167      * of the list, in the order in which they are returned by the Iterator of
168      * the RoleUnresolvedList specified.
169      *
170      * @param theRoleUnresolvedList - Elements to be inserted into the list
171      * (can be null).
172      *
173      * @return true if this list changed as a result of the call.
174      *
175      * @exception IndexOutOfBoundsException if accessing with an index
176      * outside of the list.
177      */

178     public boolean addAll(RoleUnresolvedList JavaDoc theRoleUnresolvedList)
179     throws IndexOutOfBoundsException JavaDoc {
180
181     if (theRoleUnresolvedList == null) {
182         return true;
183     }
184
185     return (super.addAll(theRoleUnresolvedList));
186     }
187
188     /**
189      * Inserts all of the elements in the RoleUnresolvedList specified into
190      * this list, starting at the specified position, in the order in which
191      * they are returned by the Iterator of the RoleUnresolvedList specified.
192      *
193      * @param index - Position at which to insert the first element from the
194      * RoleUnresolvedList specified.
195      * @param theRoleUnresolvedList - Elements to be inserted into the list.
196      *
197      * @return true if this list changed as a result of the call.
198      *
199      * @exception IllegalArgumentException if the role is null.
200      * @exception IndexOutOfBoundsException if index is out of range
201      * (<code>index &lt; 0 || index &gt; size()</code>).
202      */

203     public boolean addAll(int index,
204               RoleUnresolvedList JavaDoc theRoleUnresolvedList)
205     throws IllegalArgumentException JavaDoc,
206                IndexOutOfBoundsException JavaDoc {
207
208     if (theRoleUnresolvedList == null) {
209         String JavaDoc excMsg = "Invalid parameter";
210         throw new IllegalArgumentException JavaDoc(excMsg);
211     }
212
213     return (super.addAll(index, theRoleUnresolvedList));
214     }
215 }
216
Popular Tags