[ 
https://issues.apache.org/jira/browse/JEXL-406?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17767468#comment-17767468
 ] 

Xu Pengcheng commented on JEXL-406:
-----------------------------------

We use Interpreter to wrap object to provider more methods, for example.

 
{code:java}
Class JexlList extends List {
  ... ...
  @Override
  public String join(String splitter) {
    // ... ...
  }
}

@Override
@SuppressWarnings("unchecked")
protected Object visit(final ASTIdentifierAccess node, Object data) {
  if (data instanceof List && !(data instanceof JexlList)) {
    data = new JexlList((List<Object>) data);
  }
  return super.visit(node, data);
}

@Override
@SuppressWarnings("unchecked")
protected Object call(JexlNode node, Object target, Object functor, 
ASTArguments argNode) {
  if (Object instanceof List && !(Object instanceof JexlList)) {
    target = new JexlList((List<Object>)target);
  }
  return super.call(node, target, functor, argNode));
}{code}
Then all list in jexl context has `join` method.

 

It works while executing script but fails evaluating template.

 

> allow override Engine.createTemplateInterpreter ?
> -------------------------------------------------
>
>                 Key: JEXL-406
>                 URL: https://issues.apache.org/jira/browse/JEXL-406
>             Project: Commons JEXL
>          Issue Type: Improvement
>    Affects Versions: 3.3
>            Reporter: Xu Pengcheng
>            Assignee: Henri Biestro
>            Priority: Major
>
> I defined a Interpreter for JexlEngine but found it does not work while 
> evaluating template string, I debugged and found Interpreter of jexl is not 
> applied for TemplateEngine by default.
> I found there is a method createTemplateInterpreter in Engine.class
> {code:java}
> /**
> * Creates a template interpreter.
> * @param args the template interpreter arguments
> */
> protected Interpreter createTemplateInterpreter(final 
> TemplateInterpreter.Arguments args) {
> return new TemplateInterpreter(args);
> }{code}
> But the parameter TemplateInterpreter.Arguments is not visible outside of the 
> package, is it possible to change the visibility so that we can override it?
>  
> Thanks!



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to