程序包 org.beetl.core

接口 Function

所有已知实现类:
FileFunctionWrapper, FunctionWrapper, MutipleFunctionWrapper, SingleFunctionWrapper

public interface Function
Beetl 的函数接口,用户可以通过实现此接口来自定一方法

 例如实现一个将字符创转为大写的函数 str.upcase
 str.upcase 接收一个字符串参数,并将其转为大写,如下调用

       hello,this is ${str.upcase(user.name)}

 group.registerFunction("str.upcase", new Function() {
     public String call(Object[] paras, Context ctx) {
         String str = (String) paras[0];
         return str.toUpperCase();
     }
 });

 
从以下版本开始:
1.1
作者:
xiandafu
  • 嵌套类概要

    嵌套类
    修饰符和类型
    接口
    说明
    static interface 
    如果Function实现了此接口,则入参会在解析的时候修改
    static interface 
    如果Function还实现了此接口,则此函数参数将使用安全输出符号
    static interface 
    如果Function实现了此接口,则会添加额当前外行参
  • 方法概要

    修饰符和类型
    方法
    说明
    call(Object[] paras, Context ctx)
     
  • 方法详细资料