org.displaytag.util
Class LookupUtil

java.lang.Object
  extended by org.displaytag.util.LookupUtil

public final class LookupUtil
extends java.lang.Object

Utility class with methods for object and properties retrieving.

Version:
$Id: LookupUtil.java 1081 2006-04-03 20:26:34Z fgiust $
Author:
Fabrizio Giustina

Method Summary
static java.lang.Object getBeanProperty(java.lang.Object bean, java.lang.String name)
           Returns the value of a property in the given bean.
static java.lang.Object getBeanValue(javax.servlet.jsp.PageContext pageContext, java.lang.String beanAndPropertyName, int scope)
          Read an object from the pagecontext with the specified scope and eventually lookup a property in it.
static java.lang.Object getIndexedProperty(java.lang.Object bean, java.lang.String name)
          Return the value of the specified indexed property of the specified bean, with no type conversions.
static java.lang.Object getProperty(java.lang.Object bean, java.lang.String name)
          Return the value of the (possibly nested) property of the specified name, for the specified bean, with no type conversions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getBeanValue

public static java.lang.Object getBeanValue(javax.servlet.jsp.PageContext pageContext,
                                            java.lang.String beanAndPropertyName,
                                            int scope)
                                     throws ObjectLookupException
Read an object from the pagecontext with the specified scope and eventually lookup a property in it.

Parameters:
pageContext - PageContext
beanAndPropertyName - String expression with bean name and attributes
scope - One of the following values:
  • PageContext.PAGE_SCOPE
  • PageContext.REQUEST_SCOPE
  • PageContext.SESSION_SCOPE
  • PageContext.APPLICATION_SCOPE
Returns:
Object
Throws:
ObjectLookupException - for errors while retrieving a property in the bean

getBeanProperty

public static java.lang.Object getBeanProperty(java.lang.Object bean,
                                               java.lang.String name)
                                        throws ObjectLookupException

Returns the value of a property in the given bean.

Handle NestedNullException returning nulls and other exceptions returning ObjectLookupException.

Parameters:
bean - javabean
name - name of the property to read from the javabean
Returns:
Object
Throws:
ObjectLookupException - for errors while retrieving a property in the bean

getProperty

public static java.lang.Object getProperty(java.lang.Object bean,
                                           java.lang.String name)
                                    throws java.lang.IllegalAccessException,
                                           java.lang.reflect.InvocationTargetException,
                                           java.lang.NoSuchMethodException
Return the value of the (possibly nested) property of the specified name, for the specified bean, with no type conversions.

Parameters:
bean - Bean whose property is to be extracted
name - Possibly nested name of the property to be extracted
Returns:
Object
Throws:
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
BeanPropertyLookupException - in caso di errori nella lettura di propriet´┐Ż del bean

getIndexedProperty

public static java.lang.Object getIndexedProperty(java.lang.Object bean,
                                                  java.lang.String name)
                                           throws java.lang.IllegalAccessException,
                                                  java.lang.reflect.InvocationTargetException,
                                                  java.lang.NoSuchMethodException
Return the value of the specified indexed property of the specified bean, with no type conversions. The zero-relative index of the required value must be included (in square brackets) as a suffix to the property name, or IllegalArgumentException will be thrown. In addition to supporting the JavaBeans specification, this method has been extended to support List objects as well.

Parameters:
bean - Bean whose property is to be extracted
name - propertyname[index] of the property value to be extracted
Returns:
Object
Throws:
java.lang.IllegalAccessException - if the caller does not have access to the property accessor method
java.lang.reflect.InvocationTargetException - if the property accessor method throws an exception
java.lang.NoSuchMethodException - if an accessor method for this propety cannot be found


Copyright © 2002-2007 the Displaytag team. All Rights Reserved.