Line | Hits | Source |
---|---|---|
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 | */ | |
49 | 0 | public class IntrospectableBeanDemo { |
50 | ||
51 | public static void main(String[] args) { | |
52 | 0 | IntrospectableBean bean=null; |
53 | 0 | BeanInfo beanInfo=null; |
54 | 0 | Logger logger=null; |
55 | 0 | PropertyDescriptor[] propertyDescriptors=null; |
56 | ||
57 | BasicConfigurator.configure(); | |
58 | 0 | logger=Logger.getLogger(IntrospectableBeanDemo.class); |
59 | /** | |
60 | * create a bean | |
61 | */ | |
62 | 0 | bean = new IntrospectableBean(); |
63 | /** | |
64 | * show all properties of the bean and the methods to access them | |
65 | */ | |
66 | try | |
67 | { | |
68 | 0 | beanInfo=Introspector.getBeanInfo(bean.getClass()); |
69 | 0 | propertyDescriptors=beanInfo.getPropertyDescriptors(); |
70 | logger.debug("printing property descriptors of IntrospectableBean"); | |
71 | 0 | 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 | } | |
82 | 0 | catch (IntrospectionException exception) |
83 | { | |
84 | logger.error("", exception); | |
85 | 0 | } |
86 | ||
87 | /** | |
88 | * create JavaBeanBasedDemetrixPropertiesHolder from bean | |
89 | */ | |
90 | 0 | bean.setName("this is a test"); |
91 | ||
92 | 0 | JavaBeanBasedDemetrixPropertiesHolder demetrixBean=null; |
93 | 0 | demetrixBean=new JavaBeanBasedDemetrixPropertiesHolder(bean); |
94 | ||
95 | ||
96 | /** | |
97 | * try to retrieve the property "name" | |
98 | */ | |
99 | logger.debug("name: " + demetrixBean.getProperty("name").getValue()); | |
100 | 0 | } |
101 | ||
102 | } |
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |