net.sourceforge.stripes.util.bean
Class ListPropertyAccessor

java.lang.Object
  extended by net.sourceforge.stripes.util.bean.ListPropertyAccessor
All Implemented Interfaces:
PropertyAccessor<List<?>>

public class ListPropertyAccessor
extends Object
implements PropertyAccessor<List<?>>

Implementation of PropertyAccessor for interacting with Lists. Automatically expands the list to make the supplied list index valid for set operations, and suppresses IndexOutOfBoundsExceptions during get operations.

Since:
Stripes 1.4
Author:
Tim Fennell

Constructor Summary
ListPropertyAccessor()
           
 
Method Summary
 Object getValue(NodeEvaluation evaluation, List<?> list)
          Fetches the value stored at the index specified by the current node.
 void setValue(NodeEvaluation evaluation, List list, Object value)
          Sets the value at the index specified by the current node to the supplied value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListPropertyAccessor

public ListPropertyAccessor()
Method Detail

getValue

public Object getValue(NodeEvaluation evaluation,
                       List<?> list)
Fetches the value stored at the index specified by the current node. If the index is out of bounds, will return null.

Specified by:
getValue in interface PropertyAccessor<List<?>>
Parameters:
evaluation - the current node evaluation
list - the target list
Returns:
the corresponding item in the list, or null if the list is not long enough

setValue

public void setValue(NodeEvaluation evaluation,
                     List list,
                     Object value)
Sets the value at the index specified by the current node to the supplied value. If the list is not long enough it is expanded (filling with nulls) until it is large enough to accommodate the supplied index.

Specified by:
setValue in interface PropertyAccessor<List<?>>
Parameters:
evaluation - the current node evaluation
list - the target list
value - the value to be stored at the specified index


? Copyright 2005-2006, Stripes Development Team.