KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > taglibs > util > ImgTagBeanInfo


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.taglibs.util;
14
15 import java.beans.IntrospectionException JavaDoc;
16 import java.beans.PropertyDescriptor JavaDoc;
17 import java.beans.SimpleBeanInfo JavaDoc;
18 import java.util.ArrayList JavaDoc;
19 import java.util.List JavaDoc;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.apache.commons.lang.UnhandledException;
23
24
25 /**
26  * Bean info, needed for the "class" attribute.
27  * @author Fabrizio Giustina
28  * @version $Revision: 6341 $ ($Author: philipp $)
29  */

30 public class ImgTagBeanInfo extends SimpleBeanInfo JavaDoc {
31
32     /**
33      * List of exposed properties.
34      */

35     private String JavaDoc[] properties = new String JavaDoc[]{
36         "nodeDataName",
37         "contentNodeName",
38         "contentNodeCollectionName",
39         "inherit",
40         "altNodeDataName",
41         "class",
42         "style",
43         "id",
44         "width",
45         "height"};
46
47     /**
48      * @see java.beans.BeanInfo#getPropertyDescriptors()
49      */

50     public PropertyDescriptor JavaDoc[] getPropertyDescriptors() {
51
52         try {
53             List JavaDoc proplist = new ArrayList JavaDoc();
54             for (int j = 0; j < properties.length; j++) {
55                 proplist.add(createPropertyDescriptor(properties[j]));
56             }
57             PropertyDescriptor JavaDoc[] result = new PropertyDescriptor JavaDoc[proplist.size()];
58             return ((PropertyDescriptor JavaDoc[]) proplist.toArray(result));
59
60         }
61         catch (IntrospectionException JavaDoc ex) {
62             // should never happen
63
throw new UnhandledException(ex.getMessage(), ex);
64         }
65
66     }
67
68     /**
69      * Instantiate a property descriptor for the given property.
70      * @param propertyName property name
71      * @return property descriptor
72      * @throws IntrospectionException if the given property is not valid
73      */

74     private PropertyDescriptor JavaDoc createPropertyDescriptor(String JavaDoc propertyName) throws IntrospectionException JavaDoc {
75         return new PropertyDescriptor JavaDoc(propertyName, ImgTag.class, null, "set" + StringUtils.capitalize(propertyName));
76     }
77
78 }
79
Popular Tags