001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package javax.management.relation;
023:
024: import java.util.ArrayList;
025: import java.util.Iterator;
026: import java.util.List;
027:
028: /**
029: * A list of unresolved roles.
030: *
031: * <p><b>Revisions:</b>
032: * <p><b>20020313 Adrian Brock:</b>
033: * <ul>
034: * <li>Fix the cloning
035: * </ul>
036: *
037: * @author <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>
038: * @version $Revision: 57200 $
039: */
040: public class RoleUnresolvedList extends ArrayList {
041: // Attributes ----------------------------------------------------
042:
043: // Static --------------------------------------------------------
044:
045: // Constructors --------------------------------------------------
046:
047: /**
048: * Construct an empty RoleUnresolvedList.
049: */
050: public RoleUnresolvedList() {
051: super ();
052: }
053:
054: /**
055: * Construct a RoleUnresolvedList with an initial capacity.
056: *
057: * @param initialCapacity the initial capacity.
058: */
059: public RoleUnresolvedList(int initialCapacity) {
060: super (initialCapacity);
061: }
062:
063: /**
064: * Construct a RoleUnresolvedList from a list. It must be an ArrayList.
065: * The order of the list is maintained.
066: *
067: * @param list the list to copy from.
068: * @exception IllegalArgumentException for a null list or
069: * an list element that is not a role unresolved.
070: */
071: public RoleUnresolvedList(List list)
072: throws IllegalArgumentException {
073: super ();
074: if (list == null)
075: throw new IllegalArgumentException("Null list");
076: Iterator iterator = new ArrayList(list).iterator();
077: while (iterator.hasNext()) {
078: try {
079: add((RoleUnresolved) iterator.next());
080: } catch (ClassCastException cce) {
081: throw new IllegalArgumentException(
082: "List element is not an unresolved role.");
083: }
084: }
085: }
086:
087: // Public ---------------------------------------------------------
088:
089: /**
090: * Appends a unresolved role to the end of the list.
091: *
092: * @param roleUnresolved the new unresolved role.
093: * @exception IllegalArgumentException if the unresolved role is null
094: */
095: public void add(RoleUnresolved roleUnresolved)
096: throws IllegalArgumentException {
097: if (roleUnresolved == null)
098: throw new IllegalArgumentException("Null unresolved role");
099: super .add(roleUnresolved);
100: }
101:
102: /**
103: * Adds an unresolved role at the specified location in the list.
104: *
105: * @param index the location at which to insert the unresolved role.
106: * @param roleUnresolved the new unresolved role.
107: * @exception IllegalArgumentException if the unresolved role is null
108: * @exception IndexOutOfBoundsException if there is no such index
109: * in the list
110: */
111: public void add(int index, RoleUnresolved roleUnresolved)
112: throws IllegalArgumentException, IndexOutOfBoundsException {
113: if (roleUnresolved == null)
114: throw new IllegalArgumentException("Null unresolved role");
115: super .add(index, roleUnresolved);
116: }
117:
118: /**
119: * Appends an unresolved role list to the end of the list.
120: *
121: * @param roleUnresolvedList the unresolved role list to append (can be null).
122: * @return true if the list changes, false otherwise
123: * @exception IndexOutOfBoundsException if there is no such index
124: * in the list
125: */
126: public boolean addAll(RoleUnresolvedList roleUnresolvedList)
127: throws IndexOutOfBoundsException {
128: if (roleUnresolvedList == null)
129: return false;
130: return super .addAll(roleUnresolvedList);
131: }
132:
133: /**
134: * Inserts an unresolved role list at the specified location in the list.
135: *
136: * @param index the location at which to insert the unresolved role list.
137: * @param roleUnresolvedList the unresolved role list to insert.
138: * @return true if the list changes, false otherwise
139: * @exception IllegalArgumentException if the unresolved role list is null
140: * @exception IndexOutOfBoundsException if there is no such index
141: * in the list
142: */
143: public boolean addAll(int index,
144: RoleUnresolvedList roleUnresolvedList)
145: throws IllegalArgumentException, IndexOutOfBoundsException {
146: if (roleUnresolvedList == null)
147: throw new IllegalArgumentException(
148: "null roleUnresolvedList");
149: return super .addAll(index, roleUnresolvedList);
150: }
151:
152: /**
153: * Sets an unresolved role at the specified location in the list.
154: *
155: * @param index the location of the unresolved role to replace.
156: * @param roleUnresolved the new unresolved role.
157: * @exception IllegalArgumentException if the unresolved role is null
158: * @exception IndexOutOfBoundsException if there is no such index
159: * in the list
160: */
161: public void set(int index, RoleUnresolved roleUnresolved)
162: throws IllegalArgumentException, IndexOutOfBoundsException {
163: if (roleUnresolved == null)
164: throw new IllegalArgumentException("Null unresolved role");
165: super .set(index, roleUnresolved);
166: }
167:
168: // Array List Overrides -------------------------------------------
169:
170: // NONE! I think there was supposed to be?
171:
172: // Object Overrides -----------------------------------------------
173:
174: /**
175: * Cloning.
176: *
177: * REVIEW: The spec says to return a RoleList, that's not very much
178: * of a clone is it? It must be a typo in the RI.
179: *
180: * @return the new unresolved role list with the same unresolved roles.
181: */
182: public Object clone() {
183: return super.clone();
184: }
185: }
|