KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > uitags > util > PropertyUtils


1 package net.sf.uitags.util;
2
3
4 import javax.servlet.jsp.JspException JavaDoc;
5
6 /**
7  * Helper class that provides wrappers for Commons <code>PropertyUtils
8  * </code>'s methods. The wrapping methods free the calling code from having
9  * to handle introspection-related checked-exceptions by wrapping them
10  * inside <code>JspException</code>.
11  *
12  * @author hgani
13  * @version $Id$
14  */

15 public final class PropertyUtils {
16   /**
17    * Non-instantiable by client.
18    */

19   private PropertyUtils() {
20     super();
21   }
22
23   /**
24    * Wraps <code>PropertyUtils</code>' method with the same name
25    * and signature.
26    *
27    * @param bean the bean whose property value is to be returned
28    * @param propertyName the name of the property whose value is to be retrieved
29    * @return the value of the bean property
30    * @throws JspException wraps exceptions thrown by <code>PropertyUtils</code>
31    */

32   public static Object JavaDoc getSimpleProperty(Object JavaDoc bean, String JavaDoc propertyName)
33       throws JspException JavaDoc {
34     try {
35       return org.apache.commons.beanutils.PropertyUtils.getSimpleProperty(
36           bean, propertyName);
37     }
38     catch (Exception JavaDoc e) {
39       throw new JspException JavaDoc(e);
40     }
41   }
42
43   /**
44    * Wraps <code>PropertyUtils</code>' method with the same name
45    * and signature.
46    *
47    * @param bean the bean whose property value is to be returned
48    * @param propertyName the name of the property whose value is to be retrieved
49    * @return the value of the bean property
50    * @throws JspException wraps exceptions thrown by <code>PropertyUtils</code>
51    */

52   public static Object JavaDoc getProperty(Object JavaDoc bean, String JavaDoc propertyName)
53       throws JspException JavaDoc {
54     try {
55       return org.apache.commons.beanutils.PropertyUtils.getProperty(
56           bean, propertyName);
57     }
58     catch (Exception JavaDoc e) {
59       throw new JspException JavaDoc(e);
60     }
61   }
62 }
63
Popular Tags