File: syntax.xml

package info (click to toggle)
libcommons-jexl-java 1.1-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 1,096 kB
  • sloc: java: 9,479; xml: 1,341; makefile: 7
file content (377 lines) | stat: -rw-r--r-- 13,249 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<?xml version="1.0"?>
<!--
  Copyright 2002,2004 The Apache Software Foundation.
  
  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at
  
       http://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<document>
  <properties>
    <title>Commons JEXL Syntax</title>
  </properties>

  <body>
    <section name="Overview">
      <p>
        This reference is split up into the following sections:
        <ol>
          <li><a href="#Language Elements">Language Elements</a></li>
          <li><a href="#Literals">Literals</a></li>
          <li><a href="#Functions">Functions</a></li>
          <li><a href="#Operators">Operators</a></li>
          <li><a href="#Conditional">Conditional Statements</a></li>
        </ol>
      </p>
      <p>
        For more technical information about the JEXL Grammar, you can find the
        <a href="https://javacc.dev.java.net/">JavaCC</a> grammar for JEXL
        here: <a href="http://svn.apache.org/viewcvs.cgi/jakarta/commons/proper/jexl/trunk/src/java/org/apache/commons/jexl/parser/Parser.jj?view=markup">Parser.jj</a>
      </p>
    </section>
    <section name="Language Elements">
      <table>
        <tr><th width="15%">Item</th><th>Description</th></tr>
        <tr>
          <td>Comments</td>
          <td>
            Specified using <code>##</code> and extend to the end of line, e.g.
            <source>## This is a comment</source>
          </td>
        </tr>
        <tr>
          <td>Identifiers / variables</td>
          <td>
            Must start with <code>a-z</code>, <code>A-Z</code>, <code>_</code> or <code>$</code>.
            Can then be followed by <code>0-9</code>, <code>a-z</code>, <code>A-Z</code>, <code>_</code> or <code>$</code>.
            e.g.
            <ul>
              <li>Valid: <code>var1</code>,<code>_a99</code>,<code>$1</code></li>
              <li>Invalid: <code>9v</code>,<code>!a99</code>,<code>1$</code></li>
            </ul>
            <p>
              JEXL also supports <code>ant-style</code> variables, e.g. <source>my.dotted.var</source>
              is a valid variable name.
            </p>
            <p>
              <strong>NOTE:</strong> JEXL does not support variables with hyphens in them, e.g.
              <source>commons-logging</source> is not a valid variable, but instead is treated as a
              subtraction of the variable <code>logging</code> from the variable <code>commons</code>
            </p>
          </td>
        </tr>
        <tr>
          <td>Scripts</td>
          <td>
            A script in Jexl is made up of zero or more statements. Scripts can be read from a String, File or URL.
          </td>
        </tr>
        <tr>
          <td>Statements</td>
          <td>
            A statement can be the empty statement, the semicolon (<code>;</code>) ,  block, assignment or an expression.
            Statements are optionally terminated with a semicolon.
          </td>
        </tr>
        <tr>
          <td>Block</td>
          <td>
            A block is simply multiple statements inside curly braces (<code>{, }</code>).
          </td>
        </tr>
      </table>
    </section>
    <section name="Literals">
      <table>
        <tr><th width="15%">Item</th><th>Description</th></tr>
        <tr>
          <td>Integer Literals</td>
          <td>1 or more digits from <code>0</code> to <code>9</code></td>
        </tr>
        <tr>
          <td>Floating point Literals</td>
          <td>
            1 or more digits from <code>0</code> to <code>9</code>, followed
            by a decimal point and then one or more digits from
            <code>0</code> to <code>9</code>. 
          </td>
        </tr>
        <tr>
          <td>String literals</td>
          <td>
            Can start and end with either <code>'</code> or <code>"</code>, e.g.
            <source>"Hello world"</source> and
            <source>'Hello world'</source> are equivalent.
          </td>
        </tr>
        <tr>
          <td>Boolean literals</td>
          <td>
            The literals <code>true</code> and <code>false</code> can be used, e.g.
            <source>val1 == true</source>
          </td>
        </tr>
        <tr>
          <td>Null literal</td>
          <td>
            The null value is represented as in java using the literal <code>null</code>, e.g.
            <source>val1 == null</source>
          </td>
        </tr>
      </table>
    </section>
    <section name="Functions">
      <table>
        <tr><th width="15%">Function</th><th>Description</th></tr>
        <tr>
          <td>empty</td>
          <td>
            Returns true if the expression following is either:
            <ol>
              <li><code>null</code></li>
              <li>An empty string</li>
              <li>An array of length zero</li>
              <li>A collection of size zero</li>
              <li>An empty map</li>
            </ol>
            <source>empty(var1)</source>
          </td>
        </tr>
        <tr>
          <td>size</td>
          <td>
            Returns the information about the expression:
            <ol>
              <li>Length of an array</li>
              <li>Size of a List</li>
              <li>Size of a Map</li>
              <li>Size of a Set</li>
              <li>Length of a string</li>
            </ol>
            <source>size("Hello")</source> returns 5.
          </td>
        </tr>
      </table>
    </section>
    <section name="Operators">
      <table>
        <tr><th width="15%">Operator</th><th>Description</th></tr>
        <tr>
          <td>Boolean <code>and</code></td>
          <td>
            The usual <code>&amp;&amp;</code> operator can be used as well as the word <code>and</code>, e.g.
            <source>cond1 and cond2</source> and
            <source>cond1 &amp;&amp; cond2</source> are equivalent
          </td>
        </tr>
        <tr>
          <td>Boolean <code>or</code></td>
          <td>
            The usual <code>||</code> operator can be used as well as the word <code>or</code>, e.g.
            <source>cond1 or cond2</source> and
            <source>cond1 || cond2</source> are equivalent
          </td>
        </tr>
        <tr>
          <td>Boolean <code>not</code></td>
          <td>
            The usual <code>!</code> operator can be used as well as the word <code>not</code>, e.g.
            <source>!cond1</source> and
            <source>not cond1</source> are equivalent
          </td>
        </tr>
        <tr>
          <td>Bitwise <code>and</code></td>
          <td>
            The usual <code>&amp;</code> operator is used, e.g. 
            <source>33 &amp; 4</source>, 0010 0001 &amp; 0000 0100 = 0.
          </td>
        </tr>
        <tr>
          <td>Bitwise <code>or</code></td>
          <td>
            The usual <code>|</code> operator is used, e.g.
            <source>33 | 4</source>, 0010 0001 | 0000 0100 = 0010 0101 = 37.
          </td>
        </tr>
        <tr>
          <td>Bitwise <code>xor</code></td>
          <td>
            The usual <code>^</code> operator is used, e.g.
            <source>33 ^ 4</source>, 0010 0001 ^ 0000 0100 = 0010 0100 = 37.
          </td>
        </tr>
        <tr>
          <td>Bitwise <code>complement</code></td>
          <td>
            The usual <code>~</code> operator is used, e.g.
            <source>~33</source>, ~0010 0001 = 1101 1110 = -34.
          </td>
        </tr>
        <tr>
          <td>Equality</td>
          <td>
            The usual <code>==</code> operator can be used as well as the abbreviation <code>eq</code>.
            For example 
            <source>val1 == val2</source> and
            <source>val1 eq val2</source> are equivalent.
            <ol>
              <li>
                <code>null</code> is only ever equal to null, that is if you compare null
                to any non-null value, the result is false.
              </li>
              <li>Equality uses the java <code>equals</code> method</li>
            </ol>
          </td>
        </tr>
        <tr>
          <td>Inequality</td>
          <td>
            The usual <code>!=</code> operator can be used as well as the abbreviation <code>ne</code>.
            For example
            <source>val1 != val2</source> and
            <source>val1 ne val2</source> are equivalent.
          </td>
        </tr>
        <tr>
          <td>Less Than</td>
          <td>
            The usual <code>&lt;</code> operator can be used as well as the abbreviation <code>lt</code>.
            For example
            <source>val1 &lt; val2</source> and
            <source>val1 lt val2</source> are equivalent.
          </td>
        </tr>
        <tr>
          <td>Less Than Or Equal To</td>
          <td>
            The usual <code>&lt;=</code> operator can be used as well as the abbreviation <code>le</code>.
            For example
            <source>val1 &lt;= val2</source> and
            <source>val1 le val2</source> are equivalent.
          </td>
        </tr>
        <tr>
          <td>Greater Than</td>
          <td>
            The usual <code>&gt;</code> operator can be used as well as the abbreviation <code>gt</code>.
            For example
            <source>val1 &gt; val2</source> and
            <source>val1 gt val2</source> are equivalent.
          </td>
        </tr>
        <tr>
          <td>Greater Than Or Equal To</td>
          <td>
            The usual <code>&gt;=</code> operator can be used as well as the abbreviation <code>ge</code>.
            For example
            <source>val1 &gt;= val2</source> and
            <source>val1 ge val2</source> are equivalent.
          </td>
        </tr>
        <tr>
          <td>Addition</td>
          <td>
            The usual <code>+</code> operator is used.
            For example
            <source>val1 + val2</source>
          </td>
        </tr>
        <tr>
          <td>Subtraction</td>
          <td>
            The usual <code>-</code> operator is used.
            For example
            <source>val1 - val2</source>
          </td>
        </tr>
        <tr>
          <td>Multiplication</td>
          <td>
            The usual <code>*</code> operator is used.
            For example
            <source>val1 * val2</source>
          </td>
        </tr>
        <tr>
          <td>Division</td>
          <td>
            The usual <code>/</code> operator is used.
            For example
            <source>val1 / val2</source>
          </td>
        </tr>
        <tr>
          <td>Integer Division</td>
          <td>
            The <code>div</code> operator is used.
            For example
            <source>4 div 3</source> gives 1.
          </td>
        </tr>
        <tr>
          <td>Modulus (or remainder)</td>
          <td>
            The <code>%</code> operator is used. An alternative is the <code>mod</code>
            operator.
            For example
            <source>5 mod 2</source> gives 1 and is equivalent to <source>5 % 2</source>
          </td>
        </tr>
        <tr>
          <td>Negation</td>
          <td>
            The unary <code>-</code> operator is used.
            For example
            <source>-12</source>
          </td>
        </tr>
        <tr>
          <td>Array access</td>
          <td>
            Array elements may be accessed using either square brackets or a dotted numeral, e.g.
            <source>arr1[0]</source> and <source>arr1.0</source> are equivalent
          </td>
        </tr>
      </table>
    </section>
    <section name="Conditional">
      <table>
        <tr><th width="15%">Operator</th><th>Description</th></tr>
        <tr>
          <td>if</td>
          <td>
            Classic, if/else statement, e.g.
            <code>if ((x * 2) == 5) {y = 1;} else {y = 2;}</code>
          </td>
        </tr>
        <tr>
          <td>foreach</td>
          <td>
            Loop through items of an Array, Collection, Map, Iterator or Enumeration, e.g.
            <code>foreach (item in list) { x = x + item; }</code>
            Where <code>item</code> and <code>list</code> are variables.
          </td>
        </tr>
        <tr>
          <td>while</td>
          <td>
            Loop until a condition is satisfied, e.g.
            <code>while (x lt 10) { x = x + 2; }</code>
          </td>
        </tr>
      </table>
    </section>

  </body>
</document>