Search in sources :

Example 16 with AviatorString

use of com.googlecode.aviator.runtime.type.AviatorString in project jcasbin by casbin.

the class KeyGet2Func method call.

@Override
public AviatorObject call(Map<String, Object> env, AviatorObject arg1, AviatorObject arg2, AviatorObject arg3) {
    String key1 = FunctionUtils.getStringValue(arg1, env);
    String key2 = FunctionUtils.getStringValue(arg2, env);
    String pathVar = FunctionUtils.getStringValue(arg3, env);
    return new AviatorString(BuiltInFunctions.keyGet2Func(key1, key2, pathVar));
}
Also used : AviatorString(com.googlecode.aviator.runtime.type.AviatorString) AviatorString(com.googlecode.aviator.runtime.type.AviatorString)

Example 17 with AviatorString

use of com.googlecode.aviator.runtime.type.AviatorString in project jcasbin by casbin.

the class KeyGetFunc method call.

@Override
public AviatorObject call(Map<String, Object> env, AviatorObject arg1, AviatorObject arg2) {
    String key1 = FunctionUtils.getStringValue(arg1, env);
    String key2 = FunctionUtils.getStringValue(arg2, env);
    return new AviatorString(BuiltInFunctions.keyGetFunc(key1, key2));
}
Also used : AviatorString(com.googlecode.aviator.runtime.type.AviatorString) AviatorString(com.googlecode.aviator.runtime.type.AviatorString)

Example 18 with AviatorString

use of com.googlecode.aviator.runtime.type.AviatorString in project rebuild by getrebuild.

the class RequestFunctuin method call.

@Override
public AviatorObject call(Map<String, Object> env, AviatorObject arg1, AviatorObject arg2) {
    String requestUrl = arg1.getValue(env).toString();
    String res = null;
    try {
        res = OkHttpUtils.get(requestUrl);
    } catch (IOException ex) {
        log.error("Request fail : {}", requestUrl, ex);
    }
    return res == null ? arg2 : new AviatorString(res);
}
Also used : AviatorString(com.googlecode.aviator.runtime.type.AviatorString) AviatorString(com.googlecode.aviator.runtime.type.AviatorString) IOException(java.io.IOException)

Example 19 with AviatorString

use of com.googlecode.aviator.runtime.type.AviatorString in project rebuild by getrebuild.

the class CurrentBizunitFunction method call.

@Override
public AviatorObject call(Map<String, Object> env) {
    ID user = UserContextHolder.getUser();
    ID bizunit = (ID) Application.getUserStore().getUser(user).getOwningBizUnit().getIdentity();
    return new AviatorString(bizunit.toLiteral());
}
Also used : AviatorString(com.googlecode.aviator.runtime.type.AviatorString) ID(cn.devezhao.persist4j.engine.ID)

Example 20 with AviatorString

use of com.googlecode.aviator.runtime.type.AviatorString in project graphql-calculator by graphql-calculator.

the class FindOne method call.

@Override
public AviatorObject call(Map<String, Object> env, AviatorObject listElement, AviatorObject elementFieldName, AviatorObject envKey) {
    String elementKey = ((AviatorString) elementFieldName).getLexeme(Collections.emptyMap());
    String envLexeme = ((AviatorString) envKey).getLexeme(Collections.emptyMap());
    Object targetValue = env.get(envLexeme);
    List<Map> listValue = (List) listElement.getValue(Collections.emptyMap());
    Map result = listValue.stream().filter(map -> Objects.equals(map.get(elementKey), targetValue)).findFirst().orElse(null);
    return AviatorRuntimeJavaType.valueOf(result);
}
Also used : AviatorString(com.googlecode.aviator.runtime.type.AviatorString) AviatorObject(com.googlecode.aviator.runtime.type.AviatorObject) List(java.util.List) AviatorString(com.googlecode.aviator.runtime.type.AviatorString) Map(java.util.Map)

Aggregations

AviatorString (com.googlecode.aviator.runtime.type.AviatorString)33 Test (org.junit.Test)19 AviatorObject (com.googlecode.aviator.runtime.type.AviatorObject)14 HashMap (java.util.HashMap)11 AviatorJavaType (com.googlecode.aviator.runtime.type.AviatorJavaType)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 AbstractFunction (com.googlecode.aviator.runtime.function.AbstractFunction)3 Date (java.util.Date)3 List (java.util.List)3 Map (java.util.Map)3 ExpressionRuntimeException (com.googlecode.aviator.exception.ExpressionRuntimeException)2 NumberToken (com.googlecode.aviator.lexer.token.NumberToken)2 AviatorPattern (com.googlecode.aviator.runtime.type.AviatorPattern)2 PrintStream (java.io.PrintStream)2 Collection (java.util.Collection)2 LinkedList (java.util.LinkedList)2 ID (cn.devezhao.persist4j.engine.ID)1 AviatorEvaluator (com.googlecode.aviator.AviatorEvaluator)1 AviatorNil (com.googlecode.aviator.runtime.type.AviatorNil)1 AviatorNumber (com.googlecode.aviator.runtime.type.AviatorNumber)1