/** * The method called from {@link VarResolver}. * * <p> * Can be overridden to intercept the request and do special handling. * <br>Default implementation simply calls resolve(String). * * @param session The session object used for a single instance of a string resolution. * @param arg The inside argument of the variable. * @return The resolved value. * @throws Exception Any exception can be thrown. */ protected String doResolve(VarResolverSession session, String arg) throws Exception { return resolve(session, arg); }
x = i+1; } else { varVal = (hasInternalVar && r.allowNested() ? resolve(varVal) : varVal); try { if (r.streamed) r.resolveTo(this, out, varVal); else { String replacement = r.doResolve(this, varVal); if (replacement == null) replacement = ""; if (replacement.indexOf('$') != -1 && r.allowRecurse()) replacement = resolve(replacement); out.append(replacement);
if (v.streamed) { StringWriter sw = new StringWriter(); v.resolveTo(this, sw, val); return sw.toString(); s = v.doResolve(this, val); if (s == null) s = ""; return (v.allowRecurse() ? resolve(s) : s); } catch (VarResolverException e) { throw e;
/** * Constructor. * * @param vars The Var classes used for resolving string variables. * @param contextObjects Read-only context objects. */ public VarResolverContext(Class<? extends Var>[] vars, Map<String,Object> contextObjects) { this.vars = Arrays.copyOf(vars, vars.length); Map<String,Var> m = new ConcurrentSkipListMap<>(); for (Class<?> c : vars) { if (! isParentClass(Var.class, c)) throw new VarResolverException("Invalid variable class. Must extend from Var"); Var v = newInstance(Var.class, c); m.put(v.getName(), v); } this.varMap = unmodifiableMap(m); this.contextObjects = immutableMap(contextObjects); }
x = i+1; } else { varVal = (hasInternalVar && r.allowNested() ? resolve(varVal) : varVal); try { if (r.streamed) r.resolveTo(this, out, varVal); else { String replacement = r.doResolve(this, varVal); if (replacement == null) replacement = ""; if (replacement.indexOf('$') != -1 && r.allowRecurse()) replacement = resolve(replacement); out.append(replacement);
if (v.streamed) { StringWriter sw = new StringWriter(); v.resolveTo(this, sw, val); return sw.toString(); s = v.doResolve(this, val); if (s == null) s = ""; return (v.allowRecurse() ? resolve(s) : s); } catch (VarResolverException e) { throw e;
/** * Constructor. * * @param vars The Var classes used for resolving string variables. * @param contextObjects Read-only context objects. */ public VarResolverContext(Class<? extends Var>[] vars, Map<String,Object> contextObjects) { this.vars = Arrays.copyOf(vars, vars.length); Map<String,Var> m = new ConcurrentSkipListMap<>(); for (Class<?> c : vars) { if (! isParentClass(Var.class, c)) throw new VarResolverException("Invalid variable class. Must extend from Var"); Var v = newInstance(Var.class, c); m.put(v.getName(), v); } this.varMap = unmodifiableMap(m); this.contextObjects = immutableMap(contextObjects); }
x = i+1; } else { varVal = (hasInternalVar && r.allowNested() ? resolve(varVal) : varVal); try { if (r.streamed) r.resolveTo(this, out, varVal); else { String replacement = r.doResolve(this, varVal); if (replacement == null) replacement = ""; if (replacement.indexOf('$') != -1 && r.allowRecurse()) replacement = resolve(replacement); out.append(replacement);
if (v.streamed) { StringWriter sw = new StringWriter(); v.resolveTo(this, sw, val); return sw.toString(); s = v.doResolve(this, val); if (s == null) s = ""; return (v.allowRecurse() ? resolve(s) : s); } catch (VarResolverException e) { throw e;
/** * The method called from {@link VarResolver}. * * <p> * Can be overridden to intercept the request and do special handling. * <br>Default implementation simply calls resolve(String). * * @param session The session object used for a single instance of a string resolution. * @param arg The inside argument of the variable. * @return The resolved value. * @throws Exception Any exception can be thrown. */ protected String doResolve(VarResolverSession session, String arg) throws Exception { return resolve(session, arg); }
/** * Constructor. * * @param vars The Var classes used for resolving string variables. * @param contextObjects Read-only context objects. */ public VarResolverContext(Class<? extends Var>[] vars, Map<String,Object> contextObjects) { this.vars = Arrays.copyOf(vars, vars.length); Map<String,Var> m = new ConcurrentSkipListMap<>(); for (Class<?> c : vars) { if (! isParentClass(Var.class, c)) throw new VarResolverException("Invalid variable class. Must extend from Var"); Var v = newInstance(Var.class, c); m.put(v.getName(), v); } this.varMap = unmodifiableMap(m); this.contextObjects = immutableMap(contextObjects); }
/** * The method called from {@link VarResolver}. * * <p> * Can be overridden to intercept the request and do special handling. * <br>Default implementation simply calls resolve(String). * * @param session The session object used for a single instance of a string resolution. * @param arg The inside argument of the variable. * @return The resolved value. * @throws Exception Any exception can be thrown. */ protected String doResolve(VarResolverSession session, String arg) throws Exception { return resolve(session, arg); }