1 18 package org.objectweb.speedo.pobjects.basic; 19 20 import java.io.Serializable ; 21 import java.util.ArrayList ; 22 import java.util.Calendar ; 23 import java.util.Collection ; 24 import java.util.Date ; 25 import java.util.Iterator ; 26 import java.util.List ; 27 import java.util.Locale ; 28 29 import javax.jdo.InstanceCallbacks; 30 import javax.jdo.PersistenceManager; 31 import javax.jdo.PersistenceManagerFactory; 32 import javax.jdo.Query; 33 34 38 public class BasicA implements Serializable , InstanceCallbacks { 39 40 public final static int CALLBACK_INIT = 1; 41 static String nonPersistentField1 = "static field not persistent"; 42 final static String nonPersistentField2 = "final static field not persistent"; 43 public String f1 = null; 44 public int f2 = 0; 45 private int privateField = -1; 46 protected int protectedField = -2; 47 int noModifierField = -3; 48 private Date d; 49 private Date d2; 50 private long l; 51 protected String undeclaredField; 52 private String nonullField = "nonnull"; 53 private char[] myArrayOfchar; 54 private int checkJdoLoad = CALLBACK_INIT; 55 private int checkJdoStore = CALLBACK_INIT; 56 private int checkJdoClear = CALLBACK_INIT; 57 private int checkJdoDelete = CALLBACK_INIT; 58 private Locale locale = Locale.getDefault(); 59 60 public static List getAllBasicA(PersistenceManagerFactory pmf) { 61 PersistenceManager pm = pmf.getPersistenceManager(); 62 Query q = pm.newQuery(); 63 q.setClass(BasicA.class); 64 Collection col = (Collection ) q.execute(); 65 ArrayList al = new ArrayList (); 66 for(Iterator it= col.iterator(); it.hasNext();) { 67 al.add(it.next()); 68 } 69 q.closeAll(); 70 pm.close(); 71 return al; 72 } 73 74 75 private BasicA(String f1, int f2) { 76 this.f1 = f1; 77 if (this.f1 != null) { 78 myArrayOfchar = this.f1.toCharArray(); 79 } else { 80 myArrayOfchar = null; 81 } 82 this.f2 = f2; 83 d = getTime(); 84 l = 1234567890L; 85 undeclaredField = f1 + "_undeclared"; 86 } 87 88 protected BasicA(String f1) { 89 this(); 90 if (d == null) { 91 throw new NullPointerException ("d is null"); 92 } 93 this.f1 = f1; 94 if (this.f1 != null) { 95 myArrayOfchar = f1.toCharArray(); 96 } else { 97 myArrayOfchar = null; 98 } 99 d = getTime(); 100 l = 1234567890L; 101 undeclaredField = f1 + "_undeclared"; 102 } 103 public BasicA() { 104 d = getTime(); 105 l = 1234567890L; 106 undeclaredField = "undeclared"; 107 } 108 109 public Date getTime() { 110 return new Date ((Calendar.getInstance().getTime().getTime() / 1000) * 1000); 111 } 112 113 public String readF1() { 114 return f1; 115 } 116 117 public void writeF1(String f1) { 118 this.f1 = f1; 119 if (this.f1 != null) { 120 myArrayOfchar = f1.toCharArray(); 121 } else { 122 myArrayOfchar = null; 123 } 124 } 125 126 public int readF2() { 127 return f2; 128 } 129 130 public void writeF2(int f2) { 131 this.f2 = f2; 132 } 133 134 public void incF2() { 135 this.f2 = this.f2 + 1; 136 } 137 138 public String readF1_F2() { 139 return f1 + f2; 140 } 141 142 public void writeF1() { 143 f1 = "azerty"; 144 undeclaredField = f1.toString(); 145 myArrayOfchar = this.f1.toCharArray(); 146 } 147 148 public void writeF2() { 149 f2 = 1; 150 } 151 152 public void writeF1_F2() { 153 f1 = "qsdfgh"; 154 f2 = 2; 155 } 156 157 public void delegateWriteF1() { 158 writeF1(); 159 } 160 161 public void jdoPostLoad() { 162 checkJdoLoad++; 163 readF1_F2(); 164 } 165 166 public void jdoPreStore() { 167 checkJdoStore++; 168 } 169 170 public void jdoPreClear() { 171 checkJdoClear++; 172 } 173 174 public void jdoPreDelete() { 175 checkJdoDelete++; 176 } 177 178 public int getCheckJdoLoad() { 179 return checkJdoLoad; 180 } 181 182 public int getCheckJdoStore() { 183 return checkJdoStore; 184 } 185 186 public int getCheckJdoClear() { 187 return checkJdoClear; 188 } 189 190 public int getCheckJdoDelete() { 191 return checkJdoDelete; 192 } 193 194 public Locale getLocale() { 195 return locale; 196 } 197 198 public void setLocale(Locale l) { 199 this.locale = l; 200 } 201 202 public String getNonullField() { 203 return nonullField; 204 } 205 206 public void setNonullField(String nonullField) { 207 this.nonullField = nonullField; 208 } 209 210 public String getUndeclaredField() { 211 return undeclaredField; 212 } 213 public void setUndeclaredField(String undeclaredField) { 214 this.undeclaredField = undeclaredField; 215 } 216 } 217 | Popular Tags |