Pease Plate is hosted by
SourceForge.net Logo

Pease Plate

Expression Language

This block describes the expression language used in Pease Plate. If assumes that you know Java and focuses on the differences.

Similarities to Java

The expression language is heavily based on Java. Imagine you write something like System.out.println(...), and anything you write within this method call, you can use in Pease Plate.

Any expression is called on the working object that you provide with the render method. ${getName()} for example calls the workingObject.getName() method and adds the result as string to the template. The only important thing is, that the getName() method is public.

Automatic Property Calls

Which one is first if everything is called foobar?

First it looks for a global, public variable called foobar, then for a method that's called foobar(), then getFoobar() and finally isFoobar().

You don't need to write "get" or "is" when accessing a method, and you even can omit the braces.

${name} is the same as ${getName()} and calls the workingObject.getName() method.

${valid} is the same as ${isValid()} and calls the workingObject.getName() method.

The case is not important.

Null Handling

Pease Plate tries to handle null values for you. My advice: never ever check for null.

Most designators like ${print: ...} will handle a null value as empty string. Conditions like ${if: ...} will handle a null value as false.

Sub-calls will result in a null itself if any part is null. This means if you call ${myObject.name.toString()} and myObject is null or ${myObject.name} is null, then the result will simply be null instead of throwing an exception.

Equals and Compare

The equals command a == b and not equals command a != b will always call the Object.equals(...) method.

The compare command like a < b or a >= b will call the Comparable.compare(...) method. If the two objects are not comparable it will throw an exception. If any of the objects is null it will always be smaller than the other object.

Transformers

Transformers are something that is not available in Java. Their primary goal is to format a value for the output. You can define them globally and use them in expressions.

A transformer method typically takes a parameter, the input value, and transforms it to an output value. The notation looks like the following: ${input -> format}.

Take a look at the transformers chapter for a detailed description of how to use and create transformers.