1 /*
2 * Created on 09.03.2004
3 */
4 package org.xpcards.model;
5
6 import java.beans.BeanInfo;
7 import java.beans.Encoder;
8 import java.beans.Introspector;
9 import java.beans.PropertyDescriptor;
10 import java.util.Enumeration;
11
12 /***
13 * @author galu02
14 */
15 public class StoryPersistenceDelegate extends BasePersistenceDelegate {
16
17 protected void initialize(
18 Class type,
19 Object oldInstance,
20 Object newInstance,
21 Encoder out) {
22 try {
23 BeanInfo info = Introspector.getBeanInfo(oldInstance.getClass());
24 PropertyDescriptor[] d = info.getPropertyDescriptors();
25 for (int i = 0; d != null && i < d.length; i++) {
26 doProperty(
27 oldInstance.getClass(),
28 d[i],
29 oldInstance,
30 newInstance,
31 out);
32 }
33 writeComponents(oldInstance, newInstance, out);
34 } catch (Exception e) {
35 e.printStackTrace();
36 }
37 }
38
39 /* (non-Javadoc)
40 * @see java.beans.PersistenceDelegate#writeObject(java.lang.Object, java.beans.Encoder)
41 */
42 public void writeComponents(
43 Object oldInstance,
44 Object newinstance,
45 Encoder arg1) {
46
47 if (oldInstance instanceof Story) {
48 for (Enumeration en = ((Story) oldInstance).tasks();
49 en != null && en.hasMoreElements();
50 ) {
51 invokeStatement(
52 oldInstance,
53 "putTask",
54 new Object[] { en.nextElement()},
55 arg1);
56 }
57
58
59 }
60 }
61 }
This page was automatically generated by Maven