KickJava   Java API By Example, From Geeks To Geeks.

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


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 TableTagBeanInfo extends SimpleBeanInfo JavaDoc {
31
32     /**
33      * List of exposed properties.
34      */

35     private String JavaDoc[] properties = new String JavaDoc[]{"header", "class", "style", "id", "cellspacing", "cellpadding"};
36
37     /**
38      * @see java.beans.BeanInfo#getPropertyDescriptors()
39      */

40     public PropertyDescriptor JavaDoc[] getPropertyDescriptors() {
41
42         try {
43             List JavaDoc proplist = new ArrayList JavaDoc();
44             for (int j = 0; j < properties.length; j++) {
45                 proplist.add(createPropertyDescriptor(properties[j]));
46             }
47             PropertyDescriptor JavaDoc[] result = new PropertyDescriptor JavaDoc[proplist.size()];
48             return ((PropertyDescriptor JavaDoc[]) proplist.toArray(result));
49
50         }
51         catch (IntrospectionException JavaDoc ex) {
52             // should never happen
53
throw new UnhandledException(ex.getMessage(), ex);
54         }
55
56     }
57
58     /**
59      * Instantiate a property descriptor for the given property.
60      * @param propertyName property name
61      * @return property descriptor
62      * @throws IntrospectionException if the given property is not valid
63      */

64     private PropertyDescriptor JavaDoc createPropertyDescriptor(String JavaDoc propertyName) throws IntrospectionException JavaDoc {
65         return new PropertyDescriptor JavaDoc(propertyName, TableTag.class, null, "set" + StringUtils.capitalize(propertyName));
66     }
67
68 }
69
Popular Tags