public interface PojoPath extends PojoPropertyPath
PojoPath
is a String
that acts as expression to navigate
(traverse) the
object-web spanned by an initial Pojo
reflectively. PojoPath
is all about. For the
API-user a PojoPath
is just a String
with a specific syntax and semantic.
PojoPath
is defined as follows:PojoPath
= «Segment» | «PojoPath
».«Segment»Segment
= «Property» | «Index» | «Function» Property = [a-zA-Z][^.]*Index
= [0-9]+Function
= @[^. ]+
Pojo
.
Pojo
is a Map
, the «Property» is the key to
get
and set
the value.name of a property
of the
actual Pojo
. If the actual Pojo
does NOT have such
property, the PojoPath
will be illegal and cause a PojoPathException
.Integer
that represents the position of an ordered container. Pojo
is an array, the «Index» represents the array-index to access
a contained value.Pojo
is a List
, the «Index» is used as the
list-index to get
and set
a value.PojoPathFunction
.
prefix
'@'
and is
followed by the name of the function
. PojoPathFunction
can make assumptions on the actual Pojo
they operate on. If the actual
Pojo
does NOT follow these assumptions the PojoPath
will be illegal and
cause a PojoPathException
.PojoPath
-strings path1
and path2
and forThe following codePojoPathNavigator
navigator;PojoPathMode
mode;PojoPathContext
context;
Object result = navigator.will produce the sameget
(pojo, path1, mode, context);
result = navigator.get
(result, path2, mode, context);
result
as:
String path = path1 + "." + path2;
result = navigator.get
(pojo, path, mode, context);
Initial Pojo | PojoPath | Get -Code |
---|---|---|
Object object |
class | object.getClass() |
String string |
bytes | string.getBytes() |
Object [] array |
0 | array[0] |
List list |
0 | list.get(0) |
Map map |
key | map.get("key") |
Throwable t |
cause.cause.message.bytes.0 | t.getCause().getCause().getMessage().getBytes()[0] |
SEPARATOR
Modifier and Type | Method and Description |
---|---|
String |
getFunction()
This method gets the name of the function given by the
segment or null if it
is no function. |
Integer |
getIndex()
This method gets the index given by the
segment or null if it is no index. |
getParentPath, getPojoPath, getSegment
Integer getIndex()
segment
or null
if it is no index.
List
). segment
starts with a Latin digit, it is treated as index
and has to
be a valid
integer-value. However parsing should be done when this object is
constructed and therefore this method should never cause an exception.segment
or null
if it is no index.String getFunction()
segment
or null
if it
is no function. identifies
a
PojoPathFunction
that will be used to evaluate the segment
. segment
starts with the character PojoPathFunction.FUNCTION_NAME_PREFIX
(
'@'
), it is treated as function
.segment
excluding the first character or null
if the segment
does NOT start with PojoPathFunction.FUNCTION_NAME_PREFIX
.Copyright © 2001–2016 mmm-Team. All rights reserved.