1 package com.etymon.pj.object; 2 3 import java.io.*; 4 import java.util.*; 5 import com.etymon.pj.*; 6 7 11 public class PjArray 12 extends PjObject { 13 14 17 public PjArray() { 18 _v = new Vector(); 19 } 20 21 25 public PjArray(Vector v) { 26 _v = v; 27 } 28 29 33 public Vector getVector() { 34 return _v; 35 } 36 37 43 public long writePdf(OutputStream os) throws IOException { 44 long z = writeln(os, "["); 45 int size = _v.size(); 46 for (int x = 0; x < size; x++) { 47 z = z + ((PjObject)(_v.elementAt(x))).writePdf(os); 48 z = z + writeln(os, ""); 49 } 50 z = z + write(os, "]"); 51 return z; 52 } 53 54 59 public Object clone() throws CloneNotSupportedException { 60 return new PjArray(cloneVector()); 61 } 62 63 protected Vector cloneVector() throws CloneNotSupportedException { 64 Vector v = new Vector(_v.size()); 65 Enumeration m = _v.elements(); 66 while (m.hasMoreElements()) { 67 Object value = m.nextElement(); 68 if (value instanceof PjObject) { 69 v.addElement(((PjObject)value).clone()); 70 } else { 71 throw new CloneNotSupportedException ("Object in array is not a PjObject."); 72 } 73 } 74 return v; 75 } 76 77 87 public void renumber(Hashtable map) { 88 PjObject obj; 89 Object r; 90 int size = _v.size(); 91 for (int x = 0; x < size; x++) { 92 try { 93 obj = (PjObject)(_v.elementAt(x)); 94 if (obj instanceof PjReference) { 95 r = map.get(((PjReference)obj).getObjNumber()); 96 if (r != null) { 97 _v.setElementAt(r, x); 98 } 99 } else { 100 obj.renumber(map); 101 } 102 } 103 catch (ClassCastException e) { 104 } 106 } 107 } 108 109 protected Vector _v; 110 111 } 112 | Popular Tags |