Mercurial > dive4elements > river
changeset 8960:66ce19d2c5f1
Added new 'column' xpath function that allows to access a data-column via a name using variable replacement.
author | gernotbelger |
---|---|
date | Wed, 28 Mar 2018 14:34:55 +0200 (2018-03-28) |
parents | 175f113ed939 |
children | 8a1c6e2ad48b |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/FunctionResolver.java |
diffstat | 1 files changed, 18 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/FunctionResolver.java Wed Mar 28 14:34:20 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/FunctionResolver.java Wed Mar 28 14:34:55 2018 +0200 @@ -221,6 +221,12 @@ } }); + addFunction("column", 1, new XPathFunction() { + @Override + public Object evaluate(List args) throws XPathFunctionException { + return column(args.get(0)); + } + }); } /** @@ -578,5 +584,17 @@ } return StackFrames.NULL; } + + private Object column(Object argument) { + + if( !(argument instanceof String) ) + throw new IllegalArgumentException("Argument of 'column' function must be a string"); + + String columnName = (String) argument; + + StackFrames frms = buildHelper.frames; + + return frms.getNull(columnName); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :