001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * https://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.bcel.util; 020 021import java.io.Serializable; 022import java.util.ArrayList; 023import java.util.List; 024 025import org.apache.bcel.classfile.JavaClass; 026 027/** 028 * Utility class implementing a (typesafe) collection of JavaClass objects. Contains the most important methods of a 029 * Vector. 030 * 031 * @deprecated as of 5.1.1 - 7/17/2005 032 */ 033@Deprecated 034public class ClassVector implements Serializable { 035 036 private static final long serialVersionUID = 5600397075672780806L; 037 038 /** 039 * The vector of JavaClass objects. 040 * 041 * @deprecated Will be made private; do not access directly, use getter/setter. 042 */ 043 @Deprecated 044 protected transient List<JavaClass> vec = new ArrayList<>(); 045 046 /** 047 * Constructs a new ClassVector. 048 */ 049 public ClassVector() { 050 } 051 052 /** 053 * Adds a JavaClass to the vector. 054 * 055 * @param clazz the JavaClass to add. 056 */ 057 public void addElement(final JavaClass clazz) { 058 vec.add(clazz); 059 } 060 061 /** 062 * Gets the JavaClass at the specified index. 063 * 064 * @param index the index. 065 * @return the JavaClass at the specified index. 066 */ 067 public JavaClass elementAt(final int index) { 068 return vec.get(index); 069 } 070 071 @SuppressWarnings("unused") // SE_TRANSIENT_FIELD_NOT_RESTORED 072 private void readObjectNoData() { 073 vec = new ArrayList<>(); 074 } 075 076 /** 077 * Removes the JavaClass at the specified index. 078 * 079 * @param index the index. 080 */ 081 public void removeElementAt(final int index) { 082 vec.remove(index); 083 } 084 085 /** 086 * Converts the vector to an array. 087 * 088 * @return an array of JavaClass objects. 089 */ 090 public JavaClass[] toArray() { 091 return vec.toArray(JavaClass.EMPTY_ARRAY); 092 } 093}