Java implementation of UL4 (a cross-platform templating language) and UL4ON (a lightweight machine-readable text-based cross-platform object interchange format)
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
.hgignore
README.rst
build.gradle
gradle.properties
pom.xml
settings.gradle

README.rst

UL4

UL4 is a cross-platform templating language.

UL4ON

UL4ON is a lightweight machine-readable text-based cross-platform object serialization format.

Implementations

Apart from this Java implementation there are implementations of UL4 and UL4ON for Python, Javascript.

For UL4ON there's an implementation of UL4ON serialization for Oracle PL/SQL.

Documentation

The Python documentation contains more info on UL4 and on UL4ON.

Authors

  • Walter Dörwald
  • Andreas Gaßner
  • Alexander Lamm
  • Thoralf Hänsel

History

exp-132:

Split date object into date and datetime objects and support LocalDate and LocalDatetime Java objects. Add today() function.

exp-131:

Added support for loading the content of an object in an UL4ON dump iteratively.

exp-130

Added support for <?renderblock?> and <?renderblocks?>.

exp-129

Added support for <?renderx?>.

exp-128

Fixed an off-by-one error in smart whitespace handling.

exp-127

The string methods startswith() and endswith() now support list of strings as arguments.

exp-126

Use LinkedHashMap in CallAST and RenderAST to preserve the order of keyword arguments.

exp-125

Arrays.asList() returns immutables lists, and those don't support the UL4 method pop() for example. Creating a new mutable list from the array should fix that problem.

exp-124

To help will XSS prevention < will now be escaped as \u003c in JSON output and as \x3c in UL4ON output.

exp-123

UL4 now longer tries a disguise objects as dictionaries. I.e. for objects implementing UL4GetItemString the methods items(), keys(), values() and get() are no longer synthesized. This also means that len(), list(), item access and containment test no longer work on objects.

New functions getattr(), setattr(), hasattr() and dir() have been added, to work with attributes of objects.

A few interfaces (and their methods) have been renamed: UL4GetItemString to UL4GetAttr, UL4GetItemStringWithContext to UL4GetAttrWithContext and UL4Attributes to UL4Dir.

exp-122

The AttributeException constructor now has two arguments: The object and the key.

exp-121

When deeserializing UL4ON dumps it's now possible to pass in a "custom type registry" to customize which object get created.

exp-120

When compiling the template signature in an <?ul4?> tag fails the exception will now be properly wrapped to show the <?ul4?> tag in which the exception happened.

exp-119

Rendering or calling null now reliably produces a NotRenderableException/NotCallableException.

exp-118

Fixed a minor bug when loading an UL4ON dump of a template in source form.

exp-117

Implementations of UL4GetItem, UL4GetItemString, UL4GetItemWithContext and UL4GetItemStringWithContext are now required to throw an AttributeException when the attribute doesn't exist (instead of returning an UndefinedKey object).

Added <?doc?> tag which is available as via the Java method InterpretedTemplate.getDoc() or the doc attribute in UL4.

The template signature is now accessible as the signature attribute (and supports str() and repr()).

exp-116

Fixed asjson() output of BigDecimal objects.

exp-115

UL4ON dumps can now contain UL4 templates in "source" format, i.e. the template will be compiled when it is loaded. This is implemented to give the Oracle PL/SQL version a chance to put UL4 templates into a UL4ON dump.

Compiling an UL4 template will wrap the RecognitionException in a RuntimeException, so that the RecognitionException no longer has to be declared (or wrapped) by calling code.

exp-114

Dictionaries generated by dictionary literals and dictionary comprehensions are now ordered. Also the order of (key, value) pairs passed into an ** parameter will now be preserved.

exp-113

Calling the InterpretedTemplate constructor with the Signature argument no longer overwrites a signature specified via an <?ul4?> tag.

exp-112

Fixed a off-by-one bug in Utils.unescapeUL4String() with \x and \u escapes.

exp-111

The UL4ON decoder now records the stream position, so it can be show in exception messages.

exp-110

(Re)implemented the render method for templates (for backwards compatibility). This method will go away again eventually.

exp-109

Enhanced error messages in the UL4ON decoder.

exp-108

UL4ON now supports ordered maps (typecode e/E) for the Java type LinkedHashMap.

exp-107

Optimize output of color alpha values in CSS format (limit to 3 decimal places).

exp-106

Fixed alpha handling (byte/double) in Color.withlum().

exp-105

Added dictionary and set method clear.

Added function md5.

Expose attributes of DictItemAST, ListAST, SeqItemAST, UnpackDictItemAST and UnpackSeqItemAST to UL4.

exp-104

Added support for exception objects (i.e. the function isexception and exception attributes).

  • Added the count method for strings and lists.

istemplate() has been changed to return true if both of these interfaces are implemented: UL4CallWithContext and UL4RenderWithContext.

exp-103

Implemented changes from XIST 5.17: UL4 texts/tags now reference the template.

exp-102

sorted() now supports the key and reverse arguments.

Sets now have a method add.

Support for iterable unpacking in list and set literals has been added.

Support for dict/iterable unpacking in dict literals has been added.

Support for multiple uses of * and ** arguments in calls has been added.

repr() now produces the same output for strings as the Python version.

Support for the function ascii() has been added.

A string method splitlines() has been added.

Merged in the List/UL4Attributes fix from exp-99-8.

exp-101

repr() will now fall back to return "<classname>" for unknown instances.

Added repr support for AST, TextAST, CodeAST and InterpretedTemplate.

exp-100

Whitespace is now allowed before the tagname in UL4 tag, i.e. <? print 42 ?> will work.

Parsing json is now done with json-simple (https://code.google.com/p/json-simple/)

Closures no longer see a frozen version of the variables at the time of the <?def?> tag, but the final state of the variables (like many other programming languages do).

Updated for compatibility with XIST 5.14: smart whitespace handling and related stuff has been implemented.

exp-99-8

Changed the order of tests in the implementation of len() so that collections are checked first. This gives consistent results for len() and iterating an object if it implements both List and UL4Attributes.

exp-99-7

Fixed a bug in the changes from exp-99-6.

exp-99-6

Added support for UL4GetItemString to ItemAST.

exp-99-5

Added AbstractCombiningMapChain.

exp-99-4

Fixed AttrAST: The code path for UL4GetItemWithContext and UL4GetItemStringWithContext was wrong.

exp-99-3

The "combined" interfaces UL4GetAttributes, UL4GetSetAttributes, UL4GetSetItem and UL4GetSetItemString have been removed.

Two new interfaces UL4GetItemWithContext and UL4GetItemStringWithContext have been added. They allow to implement "dynamic attributes", i.e. attributes whose values depend on the local variables. E.g. it would be possible to implement an object double, such that double.x returns 2*x.

exp-99-2

Fixed pom file from exp-99-1.

exp-99-1

Fixed handling of signatures when calling local templates.

exp-99

Calling Function and FunctionWithContent objects now destroys the intermediate list objects that get created. This should help the Java GC clean up unused objects.

A TemplateClosure no longer can reference itself via the variables from its parents.

UL4Repr.Formatter no longer calls the visit method in the constructor. This makes it possible to subclass UL4Repr.Formatter for special output. To use the Formatter use the following code:

new UL4Repr.Formatter().visit(obj).toString()

An InterpretedTemplate can now have a signature. Calling or rendering the template will now check the variables passed in against the signature. This also works for subtemplates.

List slices now return new independent lists instead of views into the original one.

exp-98

UL4ON now uses an IdentityHashMap for recording serialized objects. This allows to serialize object loops.

Updated UL4ON to the more human readable version from XIST 5.12.

exp-97

Implement support for sets in UL4 and UL4ON.

Enhance FunctionRepr: Now cycles will be detected automatically even for classes that implement reprUL4() themselves.

exp-96-5

Only create an exception object in BoundDictMethodUpdate.call() when necessary.

exp-96-4

Fixed typo in CLOBVar.fetch().

exp-96-3

Free CLOBs in CLOBVar.fetch().

exp-96-2

Free CLOBs in ResultSetMapIterator.fetch().

exp-96-1

Fixed the precedence of the boolean not operator: Now it has a lower precedence than the comparison operators. i.e. not x in y is parsed as not (x in y).

exp-96

com.livinglogic.dbutils.Connection now has a new method execute() for executing database code that doesn't return a ResultSet.

com.livinglogic.dbutils.Connection has new methods int(), number(), str(), clob() and date() that return variable objects that can be used in query(), queryargs() and execute() to receive out parameters. The value returned is available in the value attribute.

com.livinglogic.dbutils.Connection.queryargs() no longer supports keyword arguments.

A problem with the evaluation order of arguments in calls has been fixed.

exp-95-2

Speed up FunctionAsJSON: Instead of creating many temporary strings, the code now formats the complete object into a StringBuilder.

exp-95-1

Fixed UL4 implementation of queryargs() method in com.livinglogic.dbutils.Connection.

exp-95

Fixed comparisons involving BigDecimal objects to ignore the scale.

Moved the code that registers the UL4 AST object for UL4ON into a static method register4UL4ON().

exp-94-1

Added support for list(Iterable).

exp-94

Added while loop.

The maximum runtime of templates can now be limited by using an EvaluationContext object with a milliseconds value > 0.

Merged in exp-81-3 which fixes '-escaping in JSON strings.

exp-93-1

Fixed version number.

exp-93

Slices are now handled by passing Slice objects as the index in Item.

exp-92

The bitwise operators &, |, ^, ~, << and >> (and their augmented assigment counterparts &=, |=, ^=, <<= and >>=) have been added.

If expressions have been added.

exp-91

com.livinglogic.dbutils.ResultSetMapIterator now returns the records as a org.apache.commons.collections.map.CaseInsensitiveMap, i.e. keys are case insensitive.

exp-90

Add support for attribute, item and slice assignment.

exp-89

Added bound methods. Instead of implementing UL4MethodCall/UL4MethodCallWithContext, simply return BoundMethod objects from getItemStringUL4().

exp-88

Added the UL4 functions first() and last().

exp-87

Connection.query() has been renamed to Connection.queryargs().

Connection.query() now requires at least one positional argument. Arguments alternate between fragments of the SQL query and parameters that will be embedded in the query.

exp-86

Make SetUtils methods generic.

exp-85

Add start argument to FunctionSum.

exp-84

Add FunctionSum.

exp-83

Add method SetUtils.makeExtendedSet().

Expose the text of Text nodes to templates.

exp-82

Object arrays are now supported everywhere List objects are.

exp-81-3

Fixed FunctionJSON.call(): ' may not be escaped in JSON strings according to json.org (and jQuery).

exp-81-2

Add missing Javascript escape for JSON output of templates.

exp-81-1

Fixed JSON output of templates.

exp-81

Fixed a bug in CallMeth.evaluate(), that surfaced when a * argument was present.

exp-80

Added methods abslum() and rellum() to Color.

exp-79

Fixed a comparison bug in Utils.narrowBigInteger().

exp-78

int(string) now returns a Long/BigInteger if the value overflows.

int() and com.livinglogic.dbutils.Connection now try to convert BigIntegers to a narrower format (Integer/Long) if possible.

exp-77

Added support for positional parameters in com.livinglogic.dbutils.Connection.

exp-76

Fixed strange ANTLR problems with triple quoted strings in various situations (function calls etc.)

exp-75

Keys in database records are now converted to lower case.

exp-74

Added support for triple quoted strings.

exp-73

Exception chains for compiler error now have an additional stack level that shows the tag the compile error happened in.

exp-72

Fixed a bug in the signature for Connection.query().

exp-71

FunctionAsJSON now handles UL4Attributes objects.

exp-70

Implemented function slice().

exp-69

Added interface UL4Attributes that extends UL4GetItemString and allows map style access to the attributes of an object.

Added interfaces UL4MethodCall and UL4MethodCallWithContext that allow implementing arbitrary method calls.

exp-68

Renamed package com.livinglogic.oracleutils to com.livinglogic.dbutils, since it is no longer Oracle specific.

exp-67

Added function list().

Implemented support for custom methods via the interface UL4MethodCall and UL4MethodCallWithContext.

Added support for resource cleanup in EvaluationContext.

Added utilities for exposing database connections to UL4 templates.

exp-66

removeWhitespace no longer removes the initial spaces in a string, but only the whitespace after a linefeed.

exp-65

Moved removeWhitespace into InterpretedTemplate, as it's only used there to avoid package name conflicts.

exp-64

Implemented UL4 functions.

Removed builtin UL4 functions vars and get.

Added methods append, insert, pop and update.

Removed JavaSource4Template and JavascriptSource4Template (as this was basically just a call to dumps() anyway).

Removed CompiledTemplate.

exp-63

Removed ChainedHashMap, as MapChain can be used instead now.

Removed EvaluationContext.keepWhitespace, as this would be used for all templates called, even if their value is different.

Formatting literal text is now done by the currently running template.

exp-62

Added support for the whitespace flag.

exp-61

Added support classes AbstractMapChain and MapChain.

Added support for the automatic variable stack.

Added support for nested scopes/closures.

Added support for calling functions with a mixture of positional and keyword arguments.

exp-60-1

Fixed FunctionBool for BigInteger and BigDecimal objects.

exp-60

To improve UL4 exception messages there are now several undefined objects, which give information about which key/name/index resulted in the undefined object being created.

AST nodes below the level of the tag now no longer have any location information. This information is added when the exception bubbling reaches a tag node.

exp-59

Added functions any() and all().

exp-58

format() now works for integers.

exp-57

Use StringBuilder instead of StringBuffer everywhere.

FunctionSort can now sort collections (lexicographically).

Added values method.

exp-56

Merged constant loading AST classes into one class: Const.

UL4ON can now read/write TimeDelta and MonthDelta objects.

Added the Undefined singleton.

Implemented constant folding for binary and unary operators and GetSlice.

exp-55

Added support for list/dict comprehension, generator expressions and the date function.

Added language argument to format function.

Added support for the week method.

Added support for timedelta and monthdelta objects.

Added support for the functions timedelta, istimedelta, monthdelta and ismonthdelta.

exp-54

Variable unpacking is now supported for assignment too.

exp-53

Variable unpacking in for loops can now be nested arbitrarily deep.

exp-52

Fixed implementation of And to try the first operand first.

exp-51

Added the functions min() and max().

Added a proper (threaded) implementation of InterpretedTemplate.reader().

exp-50

The UL4 parser has been ported to ANTLR. The final jar doesn't contain any Python/Jython any longer.

Moving to ANTLR made several syntax changes necessary:

  • @2012-04-16 becomes @(2012-04-16);
  • <?render x()?> becomes <?print x.render()?>;
  • <?print x.render()?> becomes <?print x.renders()?>.

UL4 templates now support the functions fromjson, asul4on, fromul4on.

The function json has been renamed to asjson.

Added support for templates and floats to UL4ON.

exp-49

Now the new style Javascript code generation is used (i.e. the code is generated by Javascript itself).

exp-48

Renamed the function first, last and firstlast to isfirst, islast and isfirstlast.

exp-47

Added support for the new UL4ON object serialization format (via the class com.livinglogic.ul4on.Utils).

exp-46

Added support for the new UL4 functions first(), last(), firstlast() and enumfl().

exp-45

Added new utility classes MapUtils, ChainedHashMap and ObjectAsMap.

Template, Opcode and Location now expose their attributes via a Map interface.

exp-44

Enhanced Location.toString() for literals.

Fixed TagException.toString() for parsing errors.

exp-43

Fixed location handling bugs with subtemplates.

Sub templates are now created by annotate().

exp-42

Updated to match the implementation in XIST 3.23 (i.e. names for templates).

exp-40

Added a new method Color.fromrepr().

exp-39

Fixed offsets into the source and the opcodes list for subtemplates.

exp-38

Updated Jython to version 2.5.2.

exp-37

Fixed comparison operator when only one of the arguments is null.

exp-36

The functionality for generating Javscript source from a template has been moved to a separate class JavascriptSource4Template.

Fixed many bugs that were detected by running the XIST test suite with templates converted to Java.

Updated commons-lang.jar to version 2.6 (StringEscapeUtils.escapeJava() was escaping '/' in version 2.4).

InterpretedTemplate now has a new method compileToJava() that can be used to compile the template into native Java code. (This generates Java source code for the template and compiles this with the help of the Java compiler).

exp-35

Sets can now be sorted.

exp-34

Iterators can now be sorted.

exp-33

Update file format to be compatible with XIST 3.15.

exp-32

Added InterpretedTemplate.reader() that returns a java.io.Reader object for reading the template output.

Removed all versions of the render methods that didn't have a variables argument.

exp-31

Added missing implementation for the contains opcode in InterpretedTemplate.Renderer().

exp-30

Added two methods InterpretedTemplate.render() that render the template output to a java.io.Writer.

exp-29

Fixed InterpretedTemplate.load() to conform to the format produced by Pythons version.

exp-28

Fixed problems with linefeeds in comments for tag code in Template.javascriptSource().

exp-27

Added a new method InterpretedTemplate.javascriptSource() that generates Javascript source from the template.

Updated date literals to used a @ suffix.

Fixed various bugs.

exp-26

Support for the UL4 methods startswith and endswith has been added.

exp-25

Support for the UL4 function randchoice has been added.

exp-24

Support for the following new date methods has been added: day, month, year, hour, minute, second, microsecond, weekday and yearday.

Date parsing has been enhanced (microseconds are still not supported).

Support for the UL4 functions random and randrange has been added.

exp-23

Add support for more number types in the 1 and 2 arg version of toInteger().

Add support for more number types to toFloat().

Add support for more number types to repr().

repr() of BigIntegers now ensures that the result contains a decimal point.

Add support for more number types and Color objects to json().

Add support for more number types to chr().

Add support for more number types to hex()/oct()/bin() and fixed the result for negative values.

Added the UL4 function utcnow() and the support method Utils.utcnow().

Added the UL4 method mimeformat() and the support method Utils.mimeformat().

The JSP render method has a Writer as argument instead of a JSPWriter.

exp-22

The build file now forces compilation with Java 1.5.

exp-21

Now Utils.format() can be called without a locale argument (which is useful for the JSP code generated by the XIST function ll.xist.ns.jsp.fromul4().

exp-20

Utils.sub(), Utils.mul(), Utils.truediv() and Utils.floordiv() now support all valid combinations of bool/int/float/string operands.

type() now returns the correct type for all Number subclasses.

Added function abs().

exp-19

Utils.add() now supports all combinations of bool/int/float operands.

exp-18

Utils.xmlescape() now uses ObjectUtils.toString() to support null.

exp-17

Fixed error for unsupported operations.

Utils.iterator() now supports Iterable not just Collection.

exp-16

Fixed bug in the block nesting check logic.

exp-15

Reverted the fix to the rgb() function (arguments are float values between 0 and 1).

exp-14

Fixed the rgb() function.

exp-13

Updated to use Jython 2.5 (i.e. Java 1.5).

All that's needed to use Jython is now in ul4jython.jar (which is generated by makejar.sh).

exp-12

Added float() and iscolor() functions.

exp-11

Added join() method.

exp-10

Added reversed() function.

exp-9

Added int() with two arguments.

Added render method.

exp-8

Added support for Long in a few spots in Utils.java.

exp-7

Added interface JSPTemplate for an UL4 template converted to JSP.

exp-6

Added <?note?> tag.

Added functions type(), vars(), zip().

Added one-arg find and rfind methods.

Added support for ** in dict literals and render calls.

Added Template method pythonSource().

Added support for color objects.

exp-5

Added printx tag/opcode.

Added string method capitalize().

Enhanced exceptions for unclosed blocks.

Added function get() and dictionary method get().

Fixed jump calculation for breaks and continues in for-blocks.

exp-4

Added support for a csvescape() function.

exp-3

The org.apache.commons package is now used to implement some of the operations.

Added support for a string method replace().

Added support for a repr() function.

exp-2

Added break and continue tags/opcodes.

exp-1

Initial version.