001: /* JFox, the OpenSource J2EE Application Server
002: *
003: * Copyright (C) 2002 huihoo.org
004: * Distributable under GNU LGPL license
005: * See the GNU Lesser General Public License for more details.
006: */
007:
008: package javax.management.relation;
009:
010: import java.util.ArrayList;
011: import java.util.List;
012:
013: /**
014: * A RoleUnresolvedList represents a list of RoleUnresolved objects,
015: * representing roles not retrieved from a relation due to a problem
016: * encountered whe trying to access (read or write to roles)
017: *
018: * @author <a href="mailto:young_yy@hotmail.org">Young Yang</a>
019: */
020:
021: public class RoleUnresolvedList extends ArrayList {
022:
023: /**
024: * Constructs an empty RoleUnresolvedList.
025: */
026: public RoleUnresolvedList() {
027: super ();
028: }
029:
030: /**
031: * Constructs an empty RoleUnresolvedList with the initial capacity
032: * specified.
033: *
034: * @param initialCapacity initial capacity
035: */
036: public RoleUnresolvedList(int initialCapacity) {
037: super (initialCapacity);
038: }
039:
040: /**
041: * Constructs a RoleUnresolvedList containing the elements of the
042: * ArrayList specified, in the order in which they are returned
043: * by the ArrayList's iterator. The RoleUnresolvedList instance has
044: * an initial capacity of 110% of the size of the ArrayList
045: * specified.
046: *
047: * @param roleUnresList roleUnresList of RoleUnresolved objects
048: *
049: * @exception IllegalArgumentException if:
050: * <P>- null parameter
051: * <P>or
052: * <P>- an element in the ArrayList is not a RoleUnresolved
053: */
054: public RoleUnresolvedList(List roleUnresList)
055: throws IllegalArgumentException {
056:
057: if (roleUnresList == null) {
058: throw new IllegalArgumentException(
059: "Invalid parameter: roleUnresList can not be null");
060: }
061:
062: for (int i = 0; i < roleUnresList.size(); i++) {
063: Object obj = roleUnresList.get(i);
064: if (!(obj instanceof RoleUnresolved)) {
065: throw new IllegalArgumentException(
066: "The element at index " + i
067: + "is not a RoleUnresolved, "
068: + obj.toString());
069: }
070: }
071: super .addAll(roleUnresList);
072: }
073:
074: /**
075: * Adds the RoleUnresolved specified as the last element of the list.
076: *
077: * @param roleUnres - the unresolved role to be added.
078: *
079: * @exception IllegalArgumentException if the unresolved role is null.
080: */
081: public void add(RoleUnresolved roleUnres)
082: throws IllegalArgumentException {
083: if (roleUnres == null) {
084: throw new IllegalArgumentException(
085: "Invalid parameter: roleUnres can not be null");
086: }
087: super .add(roleUnres);
088: }
089:
090: /**
091: * Inserts the unresolved role specified as an element at the position
092: * specified.
093: * Elements with an index greater than or equal to the current position are
094: * shifted up.
095: *
096: * @param index - The position in the list where the new
097: * RoleUnresolved object is to be inserted.
098: * @param roleUnres - The RoleUnresolved object to be inserted.
099: *
100: * @exception IllegalArgumentException if the unresolved role is null.
101: */
102: public void add(int index, RoleUnresolved roleUnres)
103: throws IllegalArgumentException, IndexOutOfBoundsException {
104: if (roleUnres == null) {
105: throw new IllegalArgumentException(
106: "Invalid parameter: roleUnres can not be null");
107: }
108: super .add(index, roleUnres);
109: }
110:
111: /**
112: * Sets the element at the position specified to be the unresolved role
113: * specified.
114: * The previous element at that position is discarded.
115: *
116: * @param index - The position specified.
117: * @param roleUnres - The value to which the unresolved role element
118: * should be set.
119: *
120: * @exception IllegalArgumentException if the unresolved role is null.
121: */
122: public void set(int index, RoleUnresolved roleUnres)
123: throws IllegalArgumentException, IndexOutOfBoundsException {
124: if (roleUnres == null) {
125: throw new IllegalArgumentException(
126: "Invalid parameter: roleUnres can not be null");
127: }
128: super .set(index, roleUnres);
129: }
130:
131: /**
132: * Appends all the elements in the RoleUnresolvedList specified to the end
133: * of the list, in the order in which they are returned by the Iterator of
134: * the RoleUnresolvedList specified.
135: *
136: * @param roleUnresolvedList - Elements to be inserted into the list
137: * (can be null).
138: *
139: * @exception IndexOutOfBoundsException if accessing with an index
140: * outside of the list.
141: */
142: public boolean addAll(RoleUnresolvedList roleUnresolvedList)
143: throws IndexOutOfBoundsException {
144: if (roleUnresolvedList == null) {
145: return true;
146: }
147: return (super .addAll(roleUnresolvedList));
148: }
149:
150: /**
151: * Inserts all of the elements in the RoleUnresolvedList specified into
152: * this list, starting at the specified position, in the order in which
153: * they are returned by the Iterator of the RoleUnresolvedList specified.
154: *
155: * @param index - Position at which to insert the first element from the
156: * RoleUnresolvedList specified.
157: * @param roleUnresolvedList - Elements to be inserted into the list.
158: *
159: * @exception IllegalArgumentException if the role is null.
160: * @exception IndexOutOfBoundsException if accessing with an index
161: * outside of the list.
162: */
163: public boolean addAll(int index,
164: RoleUnresolvedList roleUnresolvedList)
165: throws IllegalArgumentException, IndexOutOfBoundsException {
166: if (roleUnresolvedList == null) {
167: throw new IllegalArgumentException(
168: "Invalid parameter: roleUnres can not be null");
169: }
170:
171: return (super .addAll(index, roleUnresolvedList));
172: }
173:
174: /**
175: * Cloning
176: * <P>Returns a new RoleList, but no copy of the included elements.
177: */
178: public Object clone() {
179: ArrayList array = (ArrayList) (super .clone());
180: return new RoleList(array);
181: }
182: }
|