Returns the value of the system property or environment variable corresponding
to the given variable name, {@code null} if not matching any of the known
variables.

@see org.dihedron.core.variables.ValueProvider#onVariable(java.lang.String)
321368
@Override
	public String onVariable(String variable) {
		switch(variable) {
		case "USERHOME":
			return System.getProperty("user.home");
		case "WINDIR":
			return System.getenv("windir");
		case "SYSTEMROOT":
			return System.getenv("SystemRoot");
		case "COMMONPROGRAMFILES":
			return System.getenv("CommonProgramFiles");
		case "PROGRAMFILES":
			return System.getenv("ProgramFiles");
		case "TEMP":
			return System.getenv("TEMP");
		case "SYSTEMDRIVE":
			return System.getenv("SystemDrive");
		case "USERPROFILE":
			return System.getenv("USERPROFILE");
		case "APPDATA":
			return System.getenv("APPDATA");
		}
		return null;
	}
169327
public Object getVariable(Object key) {
		Object object = null;

		for (int i = working.size() - 1; i >= 0; --i) {
			Map<Object, Object> map = working.get(i);
			object = map.get(key);
			if (object != null)
				break;
		}
		if (object == null)
			object = global.get(key);

		return object;
	}
988826
private Object getPropertyObject(String variable, EvaluationContext context, boolean ignoreWarnings, boolean useEnvironment) throws ConfigEvaluatorException {
        Object realValue = null;

        // checked if we already looked up the value
        if (context.containsValue(variable)) {
            // get it from cache
            realValue = context.getValue(variable);
        } else if (XMLConfigConstants.CFG_SERVICE_PID.equals(variable)) {
            try {
                realValue = configEvaluator.getPid(context.getConfigElement().getConfigID());
                context.putValue(XMLConfigConstants.CFG_SERVICE_PID, realValue);
            } catch (ConfigNotFoundException ex) {
                throw new ConfigEvaluatorException("Could not obtain PID for configID", ex);
            }
        } else {
            // evaluate the variable

            context.push(variable);

            realValue = lookupVariableFromRegistry(variable);

            if (realValue == null) {
                // Try checking the properties. This will pick up already evaluated attributes, including flattened config
                realValue = context.getProperties().get(variable);

                if (realValue == null) {
                    // check if this is an metatype attribute
                    ExtendedAttributeDefinition attributeDef = context.getAttributeDefinition(variable);
                    if (attributeDef != null) {

                        String currentAttribute = context.getAttributeName();
                        // Get the nested info here, then set it later so that evaluating the
                        // metatype attribute here doesn't affect it
                        Set<NestedInfo> nestedInfo = context.getNestedInfo();
                        String flatPrefix = "";
                        try {
                            realValue = configEvaluator.evaluateMetaTypeAttribute(variable, context, attributeDef, flatPrefix, ignoreWarnings);
                        } finally {
                            context.setAttributeName(currentAttribute);
                            context.setNestedInfo(nestedInfo);
                        }

                    } else {
                        // check if this is just an attribute
                        ConfigElement configElement = context.getConfigElement();
                        Object rawValue = configElement.getAttribute(variable);
                        if (rawValue != null) {

                            String currentAttribute = context.getAttributeName();
                            Set<NestedInfo> nestedInfo = context.getNestedInfo();
                            try {
                                realValue = configEvaluator.evaluateSimpleAttribute(variable, rawValue, context, "", ignoreWarnings);
                            } finally {
                                context.setAttributeName(currentAttribute);
                                context.setNestedInfo(nestedInfo);
                            }

                        }
                    }
                }

                if (realValue == null) {
                    // Check if this variable points to an unevaluated flattened config
                    Map<String, ExtendedAttributeDefinition> attributeMap = context.getAttributeMap();
                    if (attributeMap != null) {
                        for (Map.Entry<String, ExtendedAttributeDefinition> entry : attributeMap.entrySet()) {
                            if (!context.isProcessed(entry.getKey()) && entry.getValue().isFlat()) {
                                try {
                                    configEvaluator.evaluateMetaTypeAttribute(entry.getKey(), context, entry.getValue(), "", true);
                                } catch (ConfigEvaluatorException ex) {
                                    // Ignore -- errors should be generated during main line processing
                                }

                            }

                        }
                        // Try again now that everything should be evaluated
                        realValue = context.getProperties().get(variable);
                    }
                }

                // Try to get an environment variable ( env.MYVAR )
                if (realValue == null && useEnvironment) {
                    realValue = lookupEnvironmentVariable(variable);
                }

                // Try to get a default value (<variable name="var" default="defaultValue"/>)
                if (realValue == null) {
                    realValue = lookupDefaultVariable(variable);
                }

                if (realValue == null) {
                    // If the value is null, add it to the context so that we don't try to evaluate it again.
                    // If the value is not null here, this is a variable that points to a configuration attribute,
                    // so we don't want to add it to the variable registry.
                    context.addDefinedVariable(variable, null);
                }
            } else {
                // Only add the variable to the context if this is a user defined variable
                context.addDefinedVariable(variable, realValue);
            }

            context.pop();

            context.putValue(variable, realValue);
        }

        return realValue;
    }
1362077
def getSystemVariable(self, remote, name):
        """"""
        if self._server is not None:
            return self._server.getSystemVariable(remote, name)
175858
public int getOrCreateVarIndex(final Variable var) {
        Integer index = this.name2idx.get(var.name());
        if (index == null) {
            index = this.name2idx.size() + 1;
            this.name2idx.put(var.name(), index);
            this.idx2name.put(index, var.name());
        }
        return index;
    }
1074509
public void collectVariables(EnvVars env, Run build, TaskListener listener) {
        EnvVars buildParameters = Utils.extractBuildParameters(build, listener);
        if (buildParameters != null) {
            env.putAll(buildParameters);
        }
        addAllWithFilter(envVars, env, filter.getPatternFilter());
        Map<String, String> sysEnv = new HashMap<>();
        Properties systemProperties = System.getProperties();
        Enumeration<?> enumeration = systemProperties.propertyNames();
        while (enumeration.hasMoreElements()) {
            String propertyKey = (String) enumeration.nextElement();
            sysEnv.put(propertyKey, systemProperties.getProperty(propertyKey));
        }
        addAllWithFilter(sysVars, sysEnv, filter.getPatternFilter());
    }
1189397
public Environment withVariables(java.util.Map<String, String> variables) {
        setVariables(variables);
        return this;
    }
1028574
static boolean hasEnvironmentVariable(String variable) {
        final String value = System.getenv(variable);
        if (value != null) {
            return true;
        }
        return false;
    }
1330552
public int lookupVariableName(String varName) {
        Integer varNoWrapper = varNameToNoMap.get(varName.toUpperCase());
        if (varNoWrapper == null) {
            return -1;
        }
        int varNo = varNoWrapper.intValue();
        return varNo;
    }
1114952
def get_env_variable(var_name, default=None):
    """"""
    try:
        return os.environ[var_name]
    except KeyError:
        if default is not None:
            return default
        else:
            error_msg = 'The environment variable {} was missing, abort...'\
                        .format(var_name)
            raise EnvironmentError(error_msg)
45546
public java.lang.String getVariableName() {
    java.lang.Object ref = variableName_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = 
          (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      variableName_ = s;
      return s;
    }
  }
830842
private String getValue(FilterConfig filterConfig, String initParam, String variable) {
        final String value = filterConfig.getInitParameter(initParam);
        if (StringUtils.isNotBlank(value)) {
            return value;
        } else {
            return variable;
        }
    }
322815
public boolean isGlobalVariable(@Nullable final String variableName) {
    boolean result = false;
    if (variableName != null) {
      final String normalized = PreprocessorUtils.normalizeVariableName(variableName);
      result = this.globalVarTable.containsKey(normalized) || mapVariableNameToSpecialVarProcessor.containsKey(normalized);
    }
    return result;
  }
954557
def setSystemVariable(self, remote, name, value):
        """"""
        if self._server is not None:
            return self._server.setSystemVariable(remote, name, value)
1051036
public static void setLocalVar(ExecutionContext context, String name, Object value) {
        LexicalEnvironment localEnv = context.getLexicalEnvironment();
        localEnv.getRecord().createMutableBinding(context, name, false);
        localEnv.getRecord().setMutableBinding(context, name, value, false);
    }
1091141
public boolean arrayAlreadyExistsForVarName(String varName) {
        SDVariable var = getVariable(varName);
        switch(var.getVariableType()){
            case VARIABLE:
                return variablesArrays.containsKey(varName);
            case ARRAY:
                long tid = Thread.currentThread().getId();
                return sessions.containsKey(tid) && sessions.get(tid).contains(varName, InferenceSession.OUTER_FRAME, 0, null);
            case CONSTANT:
                return constantArrays.containsKey(varName);
            case PLACEHOLDER:
                return placeholdersPerThread.containsKey(Thread.currentThread().getId()) &&
                        placeholdersPerThread.get(Thread.currentThread().getId()).containsKey(varName);
            default:
                throw new RuntimeException("Unknown variable type: " + var.getVariableType());
        }
    }
704422
@Override
    public String getValue(final String variable) throws NotAvailableException {
        try {
            return VariableProcessor.resolveVariables(VariableProcessor.resolveVariable(variable, variableProviderPool), true, variableProviderPool);
        } catch (MultiException ex) {
            throw new NotAvailableException("Variable[" + variable + "]", ex);
        }
    }