You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by he...@apache.org on 2018/02/07 11:13:22 UTC

[commons-jexl] branch master updated: JEXL-252, JEXL-250: syntax documentation

This is an automated email from the ASF dual-hosted git repository.

henrib pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jexl.git


The following commit(s) were added to refs/heads/master by this push:
     new 9c4433b  JEXL-252, JEXL-250: syntax documentation
9c4433b is described below

commit 9c4433bfef6e8d7d00dd059223ac1ab319e64a46
Author: Henri Biestro <he...@apache.org>
AuthorDate: Wed Feb 7 12:12:48 2018 +0100

    JEXL-252, JEXL-250: syntax documentation
---
 src/site/xdoc/reference/syntax.xml | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/site/xdoc/reference/syntax.xml b/src/site/xdoc/reference/syntax.xml
index 5ccad6b..e0ac82d 100644
--- a/src/site/xdoc/reference/syntax.xml
+++ b/src/site/xdoc/reference/syntax.xml
@@ -194,12 +194,21 @@
                 <tr>
                     <td>Access Operator</td>
                     <td>
-                        Allows to evaluate a property of an object, a value of the collection or an array
+                        <p>Allows to evaluate a property of an object, a value of the collection or an array
                         by using either square brackets or a dotted numeral, e.g.
                         <code>foo.bar</code> will access the <code>bar</code> property
                         of the <code>foo</code> Object.
                         <code>arr1[0]</code> will access the first element of the
-                        of the <code>arr1</code> array.
+                        of the <code>arr1</code> array.</p>
+                        <p>The safe-access operator <code>foo?.bar</code> shortcuts any null or non-existent references
+                        along the navigation path, allowing a safe-navigation free of errors. In the previous expression,
+                        if 'foo' is null, the whole expression will evaluate as null. This is an efficient shortcut
+                        to defensive expressions such as <code>x?.y?.z</code> that would otherwise be expressed as
+                        <code>x? (x.y? (x.y.z ?: null) :null) : null</code>.</p>
+                        <p>Properties can also be quoted as in <code>foo.'b a r'</code> and can be dynamic
+                        back-quoted interpolation strings as in <code>cal.`${dd.year}-${dd.month}-${dd.day}`</code>.
+                        These syntaxes are mixable with safe-access as in <code>foo.'b a r'?.quux</code> or <code>
+                            foo?.`${bar}`.quux</code>.</p>
                         <p>Access operators can be overloaded in <code>JexlArithmetic</code>, so that
                            the operator behaviour will differ depending on the type of the operator arguments</p>
                     </td>

-- 
To stop receiving notification emails like this one, please contact
henrib@apache.org.