1 3 package org.jmock.examples.website; 4 5 import java.beans.IntrospectionException ; 6 import java.beans.MethodDescriptor ; 7 import java.beans.PropertyDescriptor ; 8 import java.beans.SimpleBeanInfo ; 9 import java.util.ArrayList ; 10 11 12 public class PersonBeanInfo extends SimpleBeanInfo 13 { 14 ArrayList properties = new ArrayList (); 15 ArrayList methods = new ArrayList (); 16 17 public PersonBeanInfo() throws IntrospectionException { 18 Class beanClass = Person.class; 19 20 properties.add(new PropertyDescriptor ("name", beanClass, "name", null)); 21 properties.add(new PropertyDescriptor ("age", beanClass, "age", null)); 22 properties.add(new PropertyDescriptor ("spouse", beanClass, "spouse", null)); 23 properties.add(new PropertyDescriptor ("children", beanClass, "children", null)); 24 25 try { 26 methods.add(new MethodDescriptor (beanClass.getMethod("birth", new Class [0]))); 27 methods.add(new MethodDescriptor (beanClass.getMethod("school", new Class [0]))); 28 methods.add(new MethodDescriptor (beanClass.getMethod("work", new Class [0]))); 29 methods.add(new MethodDescriptor (beanClass.getMethod("death", new Class [0]))); 30 } 31 catch (NoSuchMethodException ex) { 32 throw new IntrospectionException (ex.getMessage()); 33 } 34 } 35 36 public MethodDescriptor [] getMethodDescriptors() { 37 return (MethodDescriptor [])methods.toArray(new MethodDescriptor [methods.size()]); 38 } 39 40 public PropertyDescriptor [] getPropertyDescriptors() { 41 return (PropertyDescriptor [])properties.toArray(new PropertyDescriptor [properties.size()]); 42 } 43 } 44 | Popular Tags |