comparison artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/FunctionResolver.java @ 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
parents 5e38e2924c07
children 5030c46d8cb4
comparison
equal deleted inserted replaced
8959:175f113ed939 8960:66ce19d2c5f1
219 public Object evaluate(List args) throws XPathFunctionException { 219 public Object evaluate(List args) throws XPathFunctionException {
220 return minNumber(args.get(0)); 220 return minNumber(args.get(0));
221 } 221 }
222 }); 222 });
223 223
224 addFunction("column", 1, new XPathFunction() {
225 @Override
226 public Object evaluate(List args) throws XPathFunctionException {
227 return column(args.get(0));
228 }
229 });
224 } 230 }
225 231
226 /** 232 /**
227 * Create a new function. 233 * Create a new function.
228 * @param name Name of the function. 234 * @param name Name of the function.
576 return x; 582 return x;
577 } 583 }
578 } 584 }
579 return StackFrames.NULL; 585 return StackFrames.NULL;
580 } 586 }
587
588 private Object column(Object argument) {
589
590 if( !(argument instanceof String) )
591 throw new IllegalArgumentException("Argument of 'column' function must be a string");
592
593 String columnName = (String) argument;
594
595 StackFrames frms = buildHelper.frames;
596
597 return frms.getNull(columnName);
598 }
581 } 599 }
582 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 600 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org