Expression Language

Some tasks can be configured with a powerful expression language (EL). The syntax of this language resembles that of the expression language in Java Server Pages. A simple expression for a filename pattern in the EL could be: ${artists[0]}/${album}/${title}.mp3

Expression are simply strings, in which logic can be embedded with ${...} constructions.

Variables

Variables can be provided by the context in which the expressions are executed (consult the documentation of the various tasks for which expressions can be used). Additionally, the framework provides a number of standard variables for each mp3 audio file:

${album} The album (a string).
${albumArtists} The album artists.
${artists} The artists of the song (a list of strings).
${comment} A comment (a string).
${compilation} Boolean, true for compilation albums.
${composers} The composers.
${disc} The disc sequence number, when the album is split over multiple discs.
${genres} The genres of the song (a list of strings, such as 'Soundtrack' or 'Alternative').
${title} The title of the track (a string).
${track} The content of the track number tag (an integer).
${trackCount} The total number of tracks for the album (an integer).
${year} The content of the year tag (an integer).

TODO: add albumGain, albumPeak, trackGain, trackPeak to this doc. TODO: add file, path

If the variable does not have a value (because the tag is not present in the audio file), it is treated as null . Null values are not written to the final string. Thus if the artists tag is not set ${artists} will evaluate to an empty string.

Properties of variables are accessed using the . operator and can be nested arbitrarily. For more expressive language features to access properties of objects, see the Expression Language syntax description from Sun

Operators

EL provides the following operators:

  • Arithmetic: + , - (binary), * , / and div , % and mod , - (unary)
  • Logical: and , && , or , || , not , !
  • Relational: == , eq , != , ne , < , lt , > , gt , <= , ge , >= , le . Comparisons can be made against other values, or against boolean, string, integer, or floating point literals.
  • Conditional: A ? B : C . Evaluate B or C , depending on the result of the evaluation of A .
  • Empty: The empty operator is a prefix operation that can be used to determine whether a value is null or empty, e.g. ${empty artists ? "no artist" : artists} .

The precedence of operators highest to lowest, left to right is as follows:

  1. [] .
  2. () (Used to change the precedence of operators).
  3. - (unary) not ! empty
  4. * / div % mod
  5. + - (binary)
  6. < > <= >= lt gt le ge
  7. == != eq ne
  8. && and
  9. || or
  10. ? :

Functions

The following function are provided:

${memberOf(object,artists)} Evaluates to true if object is an element of collection .
E.g. ${memberOf(\"Moloko\",artists)}
${strCat("str1","str2")} Evaluates to str1str2
${toLower("strING")} Evaluates to string
${toInteger("190")} Transformes objects to strings if possible.
E.g. ${toInteger("2")+toInteger("3")} Evaluates to 5
${toUpper("strING")} Evaluates to STRING
${twoDigit("3")} Used for track numbers, evaluates to 03

For more information follow this link: api documentation for the provided functions