1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * https://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.bcel.util;
20
21 import java.io.Serializable;
22 import java.util.ArrayList;
23 import java.util.List;
24
25 import org.apache.bcel.classfile.JavaClass;
26
27 /**
28 * Utility class implementing a (typesafe) collection of JavaClass objects. Contains the most important methods of a
29 * Vector.
30 *
31 * @deprecated as of 5.1.1 - 7/17/2005
32 */
33 @Deprecated
34 public class ClassVector implements Serializable {
35
36 private static final long serialVersionUID = 5600397075672780806L;
37
38 /**
39 * The vector of JavaClass objects.
40 *
41 * @deprecated Will be made private; do not access directly, use getter/setter.
42 */
43 @Deprecated
44 protected transient List<JavaClass> vec = new ArrayList<>();
45
46 /**
47 * Constructs a new ClassVector.
48 */
49 public ClassVector() {
50 }
51
52 /**
53 * Adds a JavaClass to the vector.
54 *
55 * @param clazz the JavaClass to add.
56 */
57 public void addElement(final JavaClass clazz) {
58 vec.add(clazz);
59 }
60
61 /**
62 * Gets the JavaClass at the specified index.
63 *
64 * @param index the index.
65 * @return the JavaClass at the specified index.
66 */
67 public JavaClass elementAt(final int index) {
68 return vec.get(index);
69 }
70
71 @SuppressWarnings("unused") // SE_TRANSIENT_FIELD_NOT_RESTORED
72 private void readObjectNoData() {
73 vec = new ArrayList<>();
74 }
75
76 /**
77 * Removes the JavaClass at the specified index.
78 *
79 * @param index the index.
80 */
81 public void removeElementAt(final int index) {
82 vec.remove(index);
83 }
84
85 /**
86 * Converts the vector to an array.
87 *
88 * @return an array of JavaClass objects.
89 */
90 public JavaClass[] toArray() {
91 return vec.toArray(JavaClass.EMPTY_ARRAY);
92 }
93 }