Class ReflectionValueExtractor
- java.lang.Object
-
- org.codehaus.plexus.interpolation.reflection.ReflectionValueExtractor
-
public class ReflectionValueExtractor extends java.lang.Object
NOTE: This class was copied from plexus-utils, to allow this library to stand completely self-contained.Using simple dotted expressions extract the values from a MavenProject instance, For example we might want to extract a value like: project.build.sourceDirectory
- Author:
- Jason van Zyl
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Object
evaluate(java.lang.String expression, java.lang.Object root)
The implementation supports indexed, nested and mapped properties.static java.lang.Object
evaluate(java.lang.String expression, java.lang.Object root, boolean trimRootToken)
The implementation supports indexed, nested and mapped properties.
-
-
-
Method Detail
-
evaluate
public static java.lang.Object evaluate(java.lang.String expression, java.lang.Object root) throws java.lang.Exception
The implementation supports indexed, nested and mapped properties.
- nested properties should be defined by a dot, i.e. "user.address.street"
- indexed properties (java.util.List or array instance) should be contains
(\\w+)\\[(\\d+)\\]
pattern, i.e. "user.addresses[1].street" - mapped properties should be contains
(\\w+)\\((.+)\\)
pattern, i.e. "user.addresses(myAddress).street"
- Parameters:
expression
- not null expressionroot
- not null object- Returns:
- the object defined by the expression
- Throws:
java.lang.Exception
- if any
-
evaluate
public static java.lang.Object evaluate(java.lang.String expression, java.lang.Object root, boolean trimRootToken) throws java.lang.Exception
The implementation supports indexed, nested and mapped properties.
- nested properties should be defined by a dot, i.e. "user.address.street"
- indexed properties (java.util.List or array instance) should be contains
(\\w+)\\[(\\d+)\\]
pattern, i.e. "user.addresses[1].street" - mapped properties should be contains
(\\w+)\\((.+)\\)
pattern, i.e. "user.addresses(myAddress).street"
- Parameters:
expression
- not null expressionroot
- not null objecttrimRootToken
- trim the token or not.- Returns:
- the object defined by the expression
- Throws:
java.lang.Exception
- if any
-
-