MVEL
![]() | This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages)
|
File:Mvel logo.png | |
Developer(s) | Mike Brock and Various Contributors |
---|---|
Stable release | 2.3.0
/ June 15, 2016 |
Written in | Java |
Operating system | Cross-platform |
Type | Expression Language (EL) |
License | Apache License |
Website | https://github.com/mvel/mvel |
MVFLEX Expression Language (MVEL) is a hybrid dynamic/statically typed, embeddable Expression Language and runtime for the Java Platform. Originally started as a utility language for an application framework, the project is now developed completely independently.
MVEL is typically used for exposing basic logic to end-users and programmers through configuration such as XML files or annotations. It may also be used to parse simple JavaBean expressions.
The runtime allows MVEL expressions to be executed either interpretively, or through a pre-compilation process with support for runtime bytecode generation to remove overhead.
Since MVEL is meant to augment Java-based software, it borrows most of its syntax directly from the Java programming language with some minor differences and additional capabilities. For example: as a side effect of MVEL's typing model, which treats class and method references as regular variables, it is possible to use both class and function pointers (but only for static methods).
<syntaxhighlight lang="java">
millis = System.currentTimeMillis;
// get millis time = millis();
</syntaxhighlight>
MVEL also allows collections to be represented as folds (or projections) in a Lisp-like syntax.
<syntaxhighlight lang="groovy">
namesOfParents = (parent.name in (children in employees));
</syntaxhighlight>
Hello world example
<syntaxhighlight lang="java">
System.out.println("Hello, world!");
</syntaxhighlight>
MVEL relies on Java namespaces and classes, but does not possess the ability to declare namespaces or classes.
Quicksort Example
Here is an example of the Quicksort algorithm implemented in MVEL 2.0, demonstrating the scripting capabilities of the language.
<syntaxhighlight lang="groovy"> import java.util.*;
// the main quicksort algorithm def quicksort(list) {
if (list.size() <= 1) { list; } else { pivot = list[0]; concat(quicksort(($ in list if $ < pivot)), pivot, quicksort(($ in list if $ > pivot))); }
}
// define method to concatenate lists. def concat(list1, pivot, list2) {
concatList = new ArrayList(list1); concatList.add(pivot); concatList.addAll(list2); concatList;
}
// create a list to sort list = [5,2,4,1,18,10,15,1,0];
// sort it! quicksort(list); </syntaxhighlight>
See also
Lua error in mw.title.lua at line 346: bad argument #2 to 'title.new' (unrecognized namespace name 'Portal').
External links
- MVEL Language Guide
- original website (not available any more)
- Pages with script errors
- Articles needing additional references from October 2014
- Articles with invalid date parameter in template
- All articles needing additional references
- Articles with topics of unclear notability from October 2014
- All articles with topics of unclear notability
- Scripting languages
- Free software programmed in Java (programming language)
- Programming language topic stubs