javap/src/main/java/sun/tools/javap/Vector.java
branchjavap
changeset 150 945817561b9a
parent 149 32653a09f0db
child 151 40f95fe90cdc
     1.1 --- a/javap/src/main/java/sun/tools/javap/Vector.java	Sat Nov 10 19:01:28 2012 +0100
     1.2 +++ b/javap/src/main/java/sun/tools/javap/Vector.java	Sat Nov 10 20:31:39 2012 +0100
     1.3 @@ -9,37 +9,49 @@
     1.4   * @author Jaroslav Tulach <jtulach@netbeans.org>
     1.5   */
     1.6  final class Vector {
     1.7 +    private Object[] arr;
     1.8 +    
     1.9      Vector() {
    1.10      }
    1.11  
    1.12      Vector(int i) {
    1.13 -        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    1.14 +        this();
    1.15      }
    1.16  
    1.17      void add(Object objectType) {
    1.18 -        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    1.19 +        addElement(objectType);
    1.20      }
    1.21      void addElement(Object obj) {
    1.22 -        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    1.23 +        setSize(size() + 1);
    1.24 +        setElementAt(obj, size());
    1.25      }
    1.26  
    1.27      int size() {
    1.28 -        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    1.29 +        return arr == null ? 0 : arr.length;
    1.30      }
    1.31  
    1.32 -    void copyInto(String[] accflags) {
    1.33 +    void copyInto(Object[] accflags) {
    1.34          throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    1.35      }
    1.36  
    1.37      Object elementAt(int index) {
    1.38 -        throw new UnsupportedOperationException("Not supported yet.");
    1.39 +        return arr[index];
    1.40      }
    1.41  
    1.42 -    void setSize(int i) {
    1.43 -        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    1.44 +    void setSize(int len) {
    1.45 +        if (arr == null) {
    1.46 +            arr = new Object[len];
    1.47 +        } else {
    1.48 +            Object[] newArr = new Object[len];
    1.49 +            int min = Math.min(len, arr.length);
    1.50 +            for (int i = 0; i < min; i++) {
    1.51 +                newArr[i] = arr[i];
    1.52 +            }
    1.53 +            arr = newArr;
    1.54 +        }
    1.55      }
    1.56  
    1.57 -    void setElementAt(String id, int token) {
    1.58 -        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    1.59 +    void setElementAt(Object val, int index) {
    1.60 +        arr[index] = val;
    1.61      }
    1.62  }