1 package net.sf.saxon.instruct; 2 3 4 10 11 public class GlobalParameterSet 12 { 13 private int[] keys = new int[10]; 14 private Object [] values = new Object [10]; 15 private int used = 0; 16 17 20 21 public GlobalParameterSet() {} 22 23 26 27 public GlobalParameterSet(GlobalParameterSet existing) { 28 for (int i=0; i<existing.used; i++) { 29 put(existing.keys[i], existing.values[i]); 30 } 31 } 32 33 39 40 public void put (int fingerprint, Object value) { 41 for (int i=0; i<used; i++) { 42 if (keys[i]==fingerprint) { 43 values[i]=value; 44 return; 45 } 46 } 47 if (used+1 > keys.length) { 48 int[] newkeys = new int[used*2]; 49 Object [] newvalues = new Object [used*2]; System.arraycopy(values, 0, newvalues, 0, used); 51 System.arraycopy(keys, 0, newkeys, 0, used); 52 values = newvalues; 53 keys = newkeys; 54 } 55 keys[used] = fingerprint; 56 values[used++] = value; 57 } 58 59 65 66 public Object get (int fingerprint) { 67 for (int i=0; i<used; i++) { 68 if (keys[i]==fingerprint) { 69 return values[i]; 70 } 71 } 72 return null; 73 } 74 75 78 79 public void clear() { 80 used = 0; 81 } 82 83 } 84 | Popular Tags |