Class DefaultResolver
java.lang.Object
org.apache.commons.beanutils.expression.DefaultResolver
- All Implemented Interfaces:
Resolver
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 specifiedname
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 aBeanInfo
class, a property named "xyz" will have a getter method namedgetXyz()
or (for boolean properties only)isXyz()
, and a setter method namedsetXyz()
. - 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 namedname2
, 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 theList
- Mapped (
name(key)
) - The JavaBean is assumed to have an property getter and setter methods with an additional attribute of typejava.lang.String
. - Combined (
name1.name2[index].name3(key)
) - Combining mapped, nested, and indexed references is also supported.
- Since:
- 1.8.0
- Version:
- $Id$
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final char
private static final char
private static final char
private static final char
private static final char
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Return the index value from the property expression or -1.Return the map key from the property expression ornull
.getProperty
(String expression) Return the property name from the property expression.boolean
Indicates whether or not the expression contains nested property expressions or not.boolean
Indicate whether the expression is for an indexed property or not.boolean
Indicate whether the expression is for a mapped property or not.Extract the next property expression from the current expression.Remove the last property expresson from the current expression.
-
Field Details
-
NESTED
private static final char NESTED- See Also:
-
MAPPED_START
private static final char MAPPED_START- See Also:
-
MAPPED_END
private static final char MAPPED_END- See Also:
-
INDEXED_START
private static final char INDEXED_START- See Also:
-
INDEXED_END
private static final char INDEXED_END- See Also:
-
-
Constructor Details
-
DefaultResolver
public DefaultResolver()Default Constructor.
-
-
Method Details
-
getIndex
Return the index value from the property expression or -1.- Specified by:
getIndex
in interfaceResolver
- Parameters:
expression
- The property expression- Returns:
- The index value or -1 if the property is not indexed
- Throws:
IllegalArgumentException
- If the indexed property is illegally formed or has an invalid (non-numeric) value.
-
getKey
Return the map key from the property expression ornull
.- Specified by:
getKey
in interfaceResolver
- Parameters:
expression
- The property expression- Returns:
- The index value
- Throws:
IllegalArgumentException
- If the mapped property is illegally formed.
-
getProperty
Return the property name from the property expression.- Specified by:
getProperty
in interfaceResolver
- Parameters:
expression
- The property expression- Returns:
- The property name
-
hasNested
Indicates whether or not the expression contains nested property expressions or not. -
isIndexed
Indicate whether the expression is for an indexed property or not. -
isMapped
Indicate whether the expression is for a mapped property or not. -
next
Extract the next property expression from the current expression. -
remove
Remove the last property expresson from the current expression.
-