View Javadoc
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 ProjectCollectionPersistenceDelegate 16 extends BasePersistenceDelegate { 17 18 protected void initialize( 19 Class type, 20 Object oldInstance, 21 Object newInstance, 22 Encoder out) { 23 try { 24 BeanInfo info = Introspector.getBeanInfo(oldInstance.getClass()); 25 PropertyDescriptor[] d = info.getPropertyDescriptors(); 26 for (int i = 0; d != null && i < d.length; i++) { 27 doProperty( 28 oldInstance.getClass(), 29 d[i], 30 oldInstance, 31 newInstance, 32 out); 33 } 34 writeComponents(oldInstance, newInstance, out); 35 } catch (Exception e) { 36 e.printStackTrace(); 37 } 38 } 39 40 /* (non-Javadoc) 41 * @see java.beans.PersistenceDelegate#writeObject(java.lang.Object, java.beans.Encoder) 42 */ 43 public void writeComponents( 44 Object oldInstance, 45 Object newinstance, 46 Encoder arg1) { 47 48 if (oldInstance instanceof ProjectsCollection) { 49 for (Enumeration en = ((ProjectsCollection) oldInstance).projects(); 50 en != null && en.hasMoreElements(); 51 ) { 52 Object o = en.nextElement(); 53 System.err.println("ProjectSource: " + o); 54 invokeStatement( 55 oldInstance, 56 "putProject", 57 new Object[] { o }, 58 arg1); 59 } 60 61 } 62 } 63 }

This page was automatically generated by Maven