Exemplo n.º 1
0
 @Override
 public String interpreter(NodeList carries, String helpers, JangodInterpreter interpreter)
     throws InterpretException {
   String[] helper = new HelperStringTokenizer(helpers).allTokens();
   if (helper.length < 2 || helper.length > 3) {
     throw new InterpretException("Tag 'set' expects 2 or 3 helper >>> " + helper.length);
   }
   String scope = SCOPE_TOP;
   if (helper.length == 3) {
     scope = helper[2].toLowerCase();
   }
   Object value = VariableFilter.compute(helper[1], interpreter);
   if (SCOPE_TOP.equals(scope)) {
     interpreter.assignRuntimeScope(helper[0], value, 1);
   } else {
     interpreter.assignRuntimeScope(helper[0], value);
   }
   return Constants.STR_BLANK;
 }
Exemplo n.º 2
0
 @Override
 public Object filter(Object object, JangodInterpreter interpreter, String... arg)
     throws InterpretException {
   if (object == null) {
     return false;
   }
   if (object instanceof Number) {
     if (arg.length != 1) {
       throw new InterpretException("filter divisible expects 1 arg >>> " + arg.length);
     }
     long factor = Long.valueOf(interpreter.resolveString(arg[0]));
     long value = ((Number) object).longValue();
     if (value % factor == 0) {
       return true;
     }
   }
   return false;
 }