1 9 package test.simple; 10 11 import org.ozoneDB.DxLib.*; 12 import org.ozoneDB.OzoneObject; 13 14 15 public class GarageImpl extends OzoneObject implements Garage { 16 String name = "Morris"; 17 DxHashMap table = new DxHashMap(); 18 DxBag list = new DxArrayBag(); 19 20 21 22 public GarageImpl() { 23 } 24 25 26 27 public void print() { 28 System.out.println(toString()); 29 } 30 31 32 33 public void printAll() throws Exception { 34 DxIterator it = table.iterator(); 35 Auto auto; 36 while ((auto = (Auto) it.next()) != null) { 37 auto.print(); 38 } 39 } 40 41 42 43 public Auto[] getAll() throws Exception { 44 Auto[] ans = new Auto[table.count()]; 45 DxIterator it = table.iterator(); 46 for (int c = 0; it.next() != null; c++) { 47 ans[c] = (Auto) it.object(); 48 } 49 return ans; 50 } 51 52 53 54 public int[] _setAll(Auto a0, int[] a1, Integer [] a2) throws Exception { 55 System.out.println("Got " + a1.length + " ints..."); 56 System.out.println("Got " + a2.length + " Integrs..."); 57 return a1; 58 } 59 60 61 62 public void setAll(Integer age) throws Exception { 63 DxIterator it = table.iterator(); 64 Auto auto; 65 while ((auto = (Auto) it.next()) != null) { 66 auto.setAge(age); 67 } 68 } 69 70 71 72 public void _addAuto(Auto auto) throws Exception { 73 table.addForKey(auto, auto.name()); 74 } 75 76 77 78 public void _newAuto(String name) throws Exception { 79 Auto auto = (Auto) database().createObject(AutoImpl.class.getName()); 80 auto.setName(name.toString()); 81 table.addForKey(auto, name); 82 list.add(auto); 83 } 84 85 86 87 public void _populate(Integer num) throws Exception { 88 for (int i = 0; i < num.intValue(); i++) { 89 String name = "Auto" + String.valueOf(i); 90 _newAuto(name); 91 } 92 } 93 94 95 96 public Auto autoForName(String search) { 97 return (Auto) table.elementForKey(search); 98 } 99 100 101 102 public void setAlter(DxInteger alter) throws Exception { 103 DxIterator it = table.iterator(); 104 Auto auto; 105 while ((auto = (Auto) it.next()) != null) { 106 auto.setAge(new Integer (alter.toInt())); 107 } 108 } 109 110 111 112 public void crunch(DxInteger num) throws Exception { 113 int n = num.toInt(); 114 for (int i = 0; i < n; i++) { 115 _newAuto(String.valueOf(i)); 116 } 117 118 DxIterator it = table.iterator(); 119 Auto auto; 120 while ((auto = (Auto) it.next()) != null) { 121 auto.age(); 122 } 123 } 124 125 126 127 public void _lockThis() throws Exception { 128 } 129 130 131 132 public void _langeTA(Garage garage) throws Exception { 133 Thread.currentThread().sleep(10000); 134 if (garage != null) { 135 garage._lockThis(); 136 } 137 } 138 139 140 143 public void done() throws Exception { 144 System.out.println(toString() + " done."); 145 DxIterator it = table.iterator(); 146 Auto auto; 147 while ((auto = (Auto) it.next()) != null) { 148 database().deleteObject(auto); 149 } 150 } 151 152 153 154 public String toString() { 155 return "Garage:" + name; 156 } 157 158 159 179 protected void finalize() throws Throwable { 180 } 182 } 183 | Popular Tags |