From 750550e6df3cf8c9013f7fa455218b8d3847e181 Mon Sep 17 00:00:00 2001 From: "pabs@pablotron.org" Date: Thu, 18 Dec 2014 15:10:23 -0500 Subject: add java implementation --- java/pablotron/luigi/Template.java | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 java/pablotron/luigi/Template.java (limited to 'java/pablotron/luigi/Template.java') diff --git a/java/pablotron/luigi/Template.java b/java/pablotron/luigi/Template.java new file mode 100644 index 0000000..2bf0bb7 --- /dev/null +++ b/java/pablotron/luigi/Template.java @@ -0,0 +1,37 @@ +package pablotron.luigi; + +import java.util.Map; +import pablotron.luigi.Parser; +import pablotron.luigi.Filter; +import pablotron.luigi.LuigiError; +import pablotron.luigi.actions.Action; + +public final class Template { + private static final String VERSION = "0.4.0"; + + private final String template; + private final Action actions[]; + private final Map filters; + + public Template( + final String template, + final Map filters + ) throws LuigiError { + this.template = template; + this.filters = filters; + this.actions = Parser.parse_template(template); + } + + public Template(final String template) throws LuigiError { + this(template, Filter.FILTERS); + } + + public String run(Map args) throws LuigiError { + StringBuilder r = new StringBuilder(); + + for (Action a: this.actions) + r.append(a.run(this.filters, args)); + + return r.toString(); + } +}; -- cgit v1.2.3