/** * Get the variable with the specified name and scope. * * @param name the name of the variable; may not be null * @param scope the variable scope; may not be null * @return the variable value; may be null if the variable is not currently set */ public String getVariable(String name, Scope scope) { name = variableName(name); return forScope(scope).get(name); }
/** * Get the variable with the specified name, from the highest priority scope that contain it. * * @param name the name of the variable; may not be null * @return the variable value; may be null if the variable is not currently set */ public String getVariable(String name) { List<ConcurrentMap<String, String>> orderedSystemVariablesByPriority = getOrderedSystemVariablesByScopePriority(); name = variableName(name); for (ConcurrentMap<String, String> variablesByScope : orderedSystemVariablesByPriority) { String variableName = variablesByScope.get(name); if (variableName != null) { return variableName; } } return null; }
/** * Set the variable with the specified scope. * * @param scope the variable scope; may be null if the session scope is to be used * @param name the name of the variable; may not be null * @param value the variable value; may be null if the value for the named variable is to be removed * @return this object for method chaining purposes; never null */ public SystemVariables setVariable(Scope scope, String name, String value) { name = variableName(name); if (value != null) { forScope(scope).put(name, value); } else { forScope(scope).remove(name); } return this; }
/** * Get the variable with the specified name and scope. * * @param name the name of the variable; may not be null * @param scope the variable scope; may not be null * @return the variable value; may be null if the variable is not currently set */ public String getVariable(String name, Scope scope) { name = variableName(name); return forScope(scope).get(name); }
/** * Get the variable with the specified name, from the highest priority scope that contain it. * * @param name the name of the variable; may not be null * @return the variable value; may be null if the variable is not currently set */ public String getVariable(String name) { List<ConcurrentMap<String, String>> orderedSystemVariablesByPriority = getOrderedSystemVariablesByScopePriority(); name = variableName(name); for (ConcurrentMap<String, String> variablesByScope : orderedSystemVariablesByPriority) { String variableName = variablesByScope.get(name); if (variableName != null) { return variableName; } } return null; }
/** * Set the variable with the specified scope. * * @param scope the variable scope; may be null if the session scope is to be used * @param name the name of the variable; may not be null * @param value the variable value; may be null if the value for the named variable is to be removed * @return this object for method chaining purposes; never null */ public SystemVariables setVariable(Scope scope, String name, String value) { name = variableName(name); if (value != null) { forScope(scope).put(name, value); } else { forScope(scope).remove(name); } return this; }