Coverage details for net.sourceforge.demetrix.test.properties.IntrospectableBeanDemo

LineHitsSource
1 /*******************************************************************************
2  * Demetrix process modelling system
3  *
4  * Copyright (c) 2003, 2004 Dimitri A. Pissarenko
5  *
6  * This file is part of Demetrix.
7  *
8  * Demetrix is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or
11  * (at your option) any later version.
12  *
13  * Demetrix is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Demetrix; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  *
22  * For further information you may
23  *
24  * - send an e-mail in Russian, German or English to dimitri.pissarenko@gmx.net
25  * - look at http://sourceforge.net/projects/demetrix/
26  * - look at http://demetrix.sourceforge.net/
27  * - look at http://members.inode.at/d.pissarenko/
28  *
29  *****************************************************************************/
30 /*
31  * Created on 15.01.2004
32  */
33 package net.sourceforge.demetrix.test.properties;
34  
35 import java.beans.BeanInfo;
36 import java.beans.IntrospectionException;
37 import java.beans.Introspector;
38 import java.beans.PropertyDescriptor;
39  
40 import net.sourceforge.demetrix.properties.JavaBeanBasedDemetrixPropertiesHolder;
41  
42 import org.apache.log4j.BasicConfigurator;
43 import org.apache.log4j.Logger;
44  
45 /**
46  * @author Dimitri Pissarenko
47  *
48  */
490public class IntrospectableBeanDemo {
50  
51     public static void main(String[] args) {
520        IntrospectableBean bean=null;
530        BeanInfo beanInfo=null;
540        Logger logger=null;
550        PropertyDescriptor[] propertyDescriptors=null;
56         
57         BasicConfigurator.configure();
580        logger=Logger.getLogger(IntrospectableBeanDemo.class);
59         /**
60          * create a bean
61          */
620        bean = new IntrospectableBean();
63         /**
64          * show all properties of the bean and the methods to access them
65          */
66         try
67         {
680            beanInfo=Introspector.getBeanInfo(bean.getClass());
690            propertyDescriptors=beanInfo.getPropertyDescriptors();
70             logger.debug("printing property descriptors of IntrospectableBean");
710            for (int i=0; i < propertyDescriptors.length; i++)
72             {
73                 logger.debug("property");
74                 logger.debug("========");
75                 logger.debug("name: " + propertyDescriptors[i].getName());
76                 logger.debug("type: " + propertyDescriptors[i].getPropertyType());
77                 logger.debug("read method: " + propertyDescriptors[i].getReadMethod());
78                 logger.debug("write method: " + propertyDescriptors[i].getWriteMethod());
79             
80             }
81         }
820        catch (IntrospectionException exception)
83         {
84             logger.error("", exception);
850        }
86         
87         /**
88          * create JavaBeanBasedDemetrixPropertiesHolder from bean
89          */
900        bean.setName("this is a test");
91         
920        JavaBeanBasedDemetrixPropertiesHolder demetrixBean=null;
930        demetrixBean=new JavaBeanBasedDemetrixPropertiesHolder(bean);
94         
95         
96         /**
97          * try to retrieve the property "name"
98          */
99         logger.debug("name: " + demetrixBean.getProperty("name").getValue());
1000    }
101     
102 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.