/** * Returns a new builder object using the settings in this resolver as a base. * * @return A new var resolver builder. */ public VarResolverBuilder builder() { return new VarResolverBuilder() .vars(ctx.getVars()) .contextObjects(ctx.getContextObjects()); }
/** * Resolve variables in the specified string. * * <p> * This is a shortcut for calling <code>createSession(<jk>null</jk>).resolve(s);</code>. * <br>This method can only be used if the string doesn't contain variables that rely on the existence of session * variables. * * @param s The input string. * @return The string with variables resolved, or the same string if it doesn't contain any variables to resolve. */ public String resolve(String s) { return createSession(null).resolve(s); }
/** * Instantiates a new clean-slate {@link VarResolverBuilder} object. * * <p> * This is equivalent to simply calling <code><jk>new</jk> VarResolverBuilder()</code>. * * @return A new {@link VarResolverBuilder} object. */ public static VarResolverBuilder create() { return new VarResolverBuilder(); }
static String[] resolveVars(VarResolver vr, String[] in) { String[] out = new String[in.length]; for (int i = 0; i < in.length; i++) out[i] = vr.resolve(in[i]); return out; }
@Override /* Object */ public String toString() { if (varSession != null) return varSession.resolve(contents); return contents; } }
/** * Same as {@link #createSession()} except allows you to specify session objects as a map. * * @param sessionObjects The session objects to associate with the session. * @return A new resolver session. */ public VarResolverSession createSession(Map<String,Object> sessionObjects) { return new VarResolverSession(ctx, sessionObjects); }
/** * Constructor. * * @param vars The var classes * @param contextObjects */ VarResolver(Class<? extends Var>[] vars, Map<String,Object> contextObjects) { this.ctx = new VarResolverContext(vars, contextObjects); }
/** * Constructor. * * @param cause The cause of this exception. * @param message The {@link MessageFormat}-style message. * @param args Optional {@link MessageFormat}-style arguments. */ public VarResolverException(Throwable cause, String message, Object... args) { super(cause, getMessage(cause, message, null), args); }
/** * Returns a new builder object using the settings in this resolver as a base. * * @return A new var resolver builder. */ public VarResolverBuilder builder() { return new VarResolverBuilder() .vars(ctx.getVars()) .contextObjects(ctx.getContextObjects()); }
/** * Resolve variables in the specified string. * * <p> * This is a shortcut for calling <code>createSession(<jk>null</jk>).resolve(s);</code>. * <br>This method can only be used if the string doesn't contain variables that rely on the existence of session * variables. * * @param s The input string. * @return The string with variables resolved, or the same string if it doesn't contain any variables to resolve. */ public String resolve(String s) { return createSession(null).resolve(s); }
private static String[] resolveVars(VarResolver vr, String[] in) { String[] out = new String[in.length]; for (int i = 0; i < in.length; i++) out[i] = vr.resolve(in[i]); return out; }
/** * Same as {@link #createSession()} except allows you to specify session objects as a map. * * @param sessionObjects The session objects to associate with the session. * @return A new resolver session. */ public VarResolverSession createSession(Map<String,Object> sessionObjects) { return new VarResolverSession(ctx, sessionObjects); }
/** * Constructor. * * @param vars The var classes * @param contextObjects */ VarResolver(Class<? extends Var>[] vars, Map<String,Object> contextObjects) { this.ctx = new VarResolverContext(vars, contextObjects); }
/** * Returns a new builder object using the settings in this resolver as a base. * * @return A new var resolver builder. */ public VarResolverBuilder builder() { return new VarResolverBuilder() .vars(ctx.getVars()) .contextObjects(ctx.getContextObjects()); }
/** * Resolve variables in the specified string. * * <p> * This is a shortcut for calling <code>createSession(<jk>null</jk>).resolve(s);</code>. * <br>This method can only be used if the string doesn't contain variables that rely on the existence of session * variables. * * @param s The input string. * @return The string with variables resolved, or the same string if it doesn't contain any variables to resolve. */ public String resolve(String s) { return createSession(null).resolve(s); }
private static String[] resolveVars(VarResolver vr, String[] in) { String[] out = new String[in.length]; for (int i = 0; i < in.length; i++) out[i] = vr.resolve(in[i]); return out; }
/** * Creates a new resolver session with no session objects. * * <p> * Session objects can be associated with the specified session using the {@link VarResolverSession#sessionObject(String, Object)} * method. * * @return A new resolver session. */ public VarResolverSession createSession() { return new VarResolverSession(ctx, null); }
static String[] resolveVars(VarResolver vr, String[] in) { String[] out = new String[in.length]; for (int i = 0; i < in.length; i++) out[i] = vr.resolve(in[i]); return out; }
/** * Creates a new resolver session with no session objects. * * <p> * Session objects can be associated with the specified session using the {@link VarResolverSession#sessionObject(String, Object)} * method. * * @return A new resolver session. */ public VarResolverSession createSession() { return new VarResolverSession(ctx, null); }
static String[] resolveVars(VarResolver vr, String[] in) { String[] out = new String[in.length]; for (int i = 0; i < in.length; i++) out[i] = vr.resolve(in[i]); return out; }