2015-05-05 Yvan Roux <yvan.roux@linaro.org>
[official-gcc.git] / libjava / classpath / javax / management / AttributeList.java
blob3d240b73bad19e91a06958f710a85a6cb593534a
1 /* AttributeList.java -- A list of MBean attributes.
2 Copyright (C) 2006 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
38 package javax.management;
40 import java.util.ArrayList;
42 /**
43 * Represents a list of MBean {@link Attribute}s, with their
44 * names and values. This is implemented as an
45 * {@link java.util.ArrayList} extension, with additional
46 * methods typed to only allow the addition of {@link Attribute}s.
48 * @author Andrew John Hughes (gnu_andrew@member.fsf.org)
49 * @since 1.5
51 public class AttributeList
52 extends ArrayList<Object>
55 /**
56 * Compatible with JDK 1.5
58 private static final long serialVersionUID = -4077085769279709076L;
60 /**
61 * Constructs an empty list with an initial capacity of ten.
63 * @see java.util.ArrayList#ArrayList()
65 public AttributeList()
67 super();
70 /**
71 * Constructs an {@link AttributeList} using the contents
72 * of an existing list. The initial capacity is 110% of the
73 * size of the specified list.
75 * @param list the list to use to fill this list.
76 * @see java.util.ArrayList#ArrayList(java.util.Collection)
78 public AttributeList(AttributeList list)
80 super(list);
83 /**
84 * Constructs an empty list with the specified initial capacity.
86 * @param capacity the initial capacity of the list.
87 * @see java.util.ArrayList#ArrayList(int)
89 public AttributeList(int capacity)
91 super(capacity);
94 /**
95 * Adds the specified {@link Attribute} to the end of the list.
97 * @param attribute the attribute to add.
98 * @see java.util.Arraylist#add(Object)
100 public void add(Attribute attribute)
102 super.add(attribute);
106 * <p>
107 * Adds the specified {@link Attribute} at the supplied index.
108 * Any attribute already at that index is moved up one place
109 * in the list to the position <code>(index + 1)</code>.
110 * Likewise, the attribute at <code>(index + 1)</code> is
111 * also moved up one place, continuing until the final
112 * attribute in the list moves to a new position, increasing
113 * the size of the list.
114 * </p>
115 * <p>
116 * If the index is invalid (i.e. it is smaller than zero, or
117 * greater than the current size of the list), a
118 * @link{RuntimeOperationsException} is thrown, which wraps
119 * the @link{IndexOutOfBoundsException} from the underlying
120 * array list.
121 * </p>
123 * @param index the index at which to place the new attribute.
124 * @param attribute the new attribute to add.
125 * @throws RuntimeOperationsException if <code>index < 0</code>
126 * or <code>index > size()</code>
127 * @see java.util.ArrayList#add(int, Object)
129 public void add(int index, Attribute attribute)
133 super.add(index, attribute);
135 catch (IndexOutOfBoundsException e)
137 throw new RuntimeOperationsException(e, "Invalid index.");
142 * Adds all the {@link Attribute}s from the supplied list
143 * to the end of this list, in the order they are returned
144 * by the list's {@link java.util.Iterator}.
146 * @param list the list of attributes to add.
147 * @return true if the list changed.
148 * @see java.util.ArrayList#addAll(Collection)
150 public boolean addAll(AttributeList list)
152 return super.addAll(list);
156 * <p>
157 * Adds all the {@link Attribute}s from the supplied list
158 * to this list, at the specified index. The attributes
159 * are added in the order they are returned by the
160 * list's {@link java.util.Iterator}. Any attribute already
161 * at that index is moved up one place in the list to the
162 * position <code>(index + list.size())</code>.
163 * Likewise, the attribute at <code>(index + list.size())</code>
164 * is also moved up one place, continuing until the final
165 * attribute in the original list.
166 * </p>
167 * <p>
168 * If the index is invalid (i.e. it is smaller than zero, or
169 * greater than the current size of the list), a
170 * @link{RuntimeOperationsException} is thrown, which wraps
171 * the @link{IndexOutOfBoundsException} from the underlying
172 * array list.
173 * </p>
175 * @param index the index at which to place the new attribute.
176 * @param list the list of attributes to add.
177 * @return true if the list changed.
178 * @throws RuntimeOperationsException if <code>index < 0</code>
179 * or <code>index > size()</code>
180 * @see java.util.ArrayList#addAll(int, Collection)
182 public boolean addAll(int index, AttributeList list)
186 return super.addAll(index, list);
188 catch (IndexOutOfBoundsException e)
190 throw new RuntimeOperationsException(e, "Invalid index.");
195 * Replaces the attribute at the specified index with the one
196 * supplied. If the index is invalid (i.e. it is smaller than
197 * zero, or greater than the current size of the list), a
198 * @link{RuntimeOperationsException} is thrown, which wraps
199 * the @link{IndexOutOfBoundsException} from the underlying
200 * array list.
202 * @param index the index at which to place the new attribute.
203 * @param attribute the new attribute to add.
204 * @throws RuntimeOperationsException if <code>index < 0</code>
205 * or <code>index > size()</code>
206 * @see java.util.ArrayList#set(int, Object)
208 public void set(int index, Attribute attribute)
212 super.set(index, attribute);
214 catch (IndexOutOfBoundsException e)
216 throw new RuntimeOperationsException(e, "Invalid index.");