org.apache.commons.beanutils.expression
Class DefaultResolver
java.lang.Object
org.apache.commons.beanutils.expression.DefaultResolver
- Resolver
public class DefaultResolver
extends java.lang.Object
Default Property Name Expression
Resolver
Implementation.
This class assists in resolving property names in the following five formats,
with the layout of an identifying String in parentheses:
- Simple (
name
) - The specified
name
identifies an individual property of a particular
JavaBean. The name of the actual getter or setter method to be used
is determined using standard JavaBeans instrospection, so that (unless
overridden by a BeanInfo
class, a property named "xyz"
will have a getter method named getXyz()
or (for boolean
properties only) isXyz()
, and a setter method named
setXyz()
. - Nested (
name1.name2.name3
) The first
name element is used to select a property getter, as for simple
references above. The object returned for this property is then
consulted, using the same approach, for a property getter for a
property named name2
, and so on. The property value that
is ultimately retrieved or modified is the one identified by the
last name element. - Indexed (
name[index]
) - The underlying
property value is assumed to be an array, or this JavaBean is assumed
to have indexed property getter and setter methods. The appropriate
(zero-relative) entry in the array is selected. List
objects are now also supported for read/write. You simply need to define
a getter that returns the List
- Mapped (
name(key)
) - The JavaBean
is assumed to have an property getter and setter methods with an
additional attribute of type java.lang.String
. - Combined (
name1.name2[index].name3(key)
) -
Combining mapped, nested, and indexed references is also
supported.
$Revision: 473888 $ $Date: 2006-11-12 06:21:24 +0000 (Sun, 12 Nov 2006) $
int | getIndex(String expression) - Return the index value from the property expression or -1.
|
String | getKey(String expression) - Return the map key from the property expression or
null .
|
String | getProperty(String expression) - Return the property name from the property expression.
|
boolean | hasNested(String expression) - Indicates whether or not the expression
contains nested property expressions or not.
|
boolean | isIndexed(String expression) - Indicate whether the expression is for an indexed property or not.
|
boolean | isMapped(String expression) - Indicate whether the expression is for a mapped property or not.
|
String | next(String expression) - Extract the next property expression from the
current expression.
|
String | remove(String expression) - Remove the last property expresson from the
current expression.
|
INDEXED_END
private static final char INDEXED_END
INDEXED_START
private static final char INDEXED_START
MAPPED_END
private static final char MAPPED_END
MAPPED_START
private static final char MAPPED_START
NESTED
private static final char NESTED
DefaultResolver
public DefaultResolver()
Default Constructor.
getIndex
public int getIndex(String expression)
Return the index value from the property expression or -1.
- getIndex in interface Resolver
expression
- The property expression
- The index value or -1 if the property is not indexed
getKey
public String getKey(String expression)
Return the map key from the property expression or null
.
- getKey in interface Resolver
expression
- The property expression
getProperty
public String getProperty(String expression)
Return the property name from the property expression.
- getProperty in interface Resolver
expression
- The property expression
hasNested
public boolean hasNested(String expression)
Indicates whether or not the expression
contains nested property expressions or not.
- hasNested in interface Resolver
expression
- The property expression
- The next property expression
isIndexed
public boolean isIndexed(String expression)
Indicate whether the expression is for an indexed property or not.
- isIndexed in interface Resolver
expression
- The property expression
true
if the expresion is indexed,
otherwise false
isMapped
public boolean isMapped(String expression)
Indicate whether the expression is for a mapped property or not.
- isMapped in interface Resolver
expression
- The property expression
true
if the expresion is mapped,
otherwise false
next
public String next(String expression)
Extract the next property expression from the
current expression.
- next in interface Resolver
expression
- The property expression
- The next property expression
remove
public String remove(String expression)
Remove the last property expresson from the
current expression.
- remove in interface Resolver
expression
- The property expression
- The new expression value, with first property
expression removed - null if there are no more expressions
Copyright (c) 2001-2007 - Apache Software Foundation