Parses an exported variable (&lt;variableName&gt; = &lt;defaultValue&gt;).
<p>
The equal symbol and default value are optional.
</p>

@param exportedVariable an exported variable (not null)
@return a map entry (key = variable name, value = default value)
434536
public static Map.Entry<String,String> parseExportedVariable( String exportedVariable ) {

		int index = exportedVariable.indexOf( '=' );
		String varName = exportedVariable, defaultValue = null;
		if( index > 0 ) {
			varName = exportedVariable.substring( 0, index ).trim();
			defaultValue = exportedVariable.substring( index + 1 ).trim();
		}

		return new AbstractMap.SimpleEntry<>( varName, defaultValue );
	}
990869
public java.lang.String getExternalValuesOrDefault(
      java.lang.String key,
      java.lang.String defaultValue) {
    if (key == null) { throw new java.lang.NullPointerException(); }
    java.util.Map<java.lang.String, java.lang.String> map =
        internalGetExternalValues().getMap();
    return map.containsKey(key) ? map.get(key) : defaultValue;
  }
21823
public static Set<String> findPrefixesForImportedVariables( Instance instance ) {
		Set<String> result = new HashSet<> ();

		for( ImportedVariable var : ComponentHelpers.findAllImportedVariables( instance.getComponent()).values())
			result.add( VariableHelpers.parseVariableName( var.getName()).getKey());

		return result;
	}
999678
public static Map<String,String> formatExportedVars( Instance instance ) {

		// The map we will return
		Map<String, String> exportedVars = new HashMap<> ();

		// Iterate over the instance and its ancestors.
		// There is no loop in parent relations, so no risk of conflict in variable names.
		for( Instance inst = instance; inst != null; inst = inst.getParent()) {

			String prefix = "";
			if( inst != instance )
				prefix = "ANCESTOR_" + inst.getComponent().getName() + "_";

			Map<String,String> exports = InstanceHelpers.findAllExportedVariables( inst );
			for(Entry<String, String> entry : exports.entrySet()) {

				// FIXME: removing the prefix may result in inconsistencies when a facet
				// and a component export variables with the same "local name".
				// And this has nothing to do with ancestors. This is about inheritance.
				String vname = prefix + VariableHelpers.parseVariableName( entry.getKey()).getValue();
				vname = vname.replaceAll( "(-|%s)+", "_" );
				exportedVars.put( vname, entry.getValue());
			}
		}

		return exportedVars;
	}
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;
    }
455860
protected String getText(String key, String defaultVal) {
    return textResource.getText(key, defaultVal);
  }
674777
public static Map<String, String> getVariableFromServerXML(BundleContext bundleContext) {
        Map<String, String> theMap = new HashMap<>();
        if (FrameworkState.isValid()) {
            ConfigVariables configVars = getConfigVariables(bundleContext);

            // Retrieve the Map of variables that have been defined in the server.xml
            theMap.putAll(configVars.getUserDefinedVariables());
        }
        return theMap;
    }
1165614
@Override
	public String onVariable(String variable) {
		String value = null;
		if(variables != null && variables.containsKey(variable)) {
			Object val = variables.get(variable);
			value = (val != null) ? val.toString() : null;
		}
		return value;
	}
1077923
public static Map<String, Object> findFreeMarkerContextVariables(Variables variables, String... varNames)
    {
        Map<String, Object> results = new HashMap<>();

        for (String varName : varNames)
        {
            WindupVertexFrame payload = null;
            try
            {
                payload = Iteration.getCurrentPayload(variables, null, varName);
            }
            catch (IllegalStateException | IllegalArgumentException e)
            {
                // oh well
            }

            if (payload != null)
            {
                results.put(varName, payload);
            }
            else
            {
                Iterable<? extends WindupVertexFrame> var = variables.findVariable(varName);
                if (var != null)
                {
                    results.put(varName, var);
                }
            }
        }
        return results;
    }
1099257
@Override
    public Map<String, String> getUserDefinedVariableDefaults() {
        HashMap<String, String> userDefinedVariables = new HashMap<String, String>();
        for (Map.Entry<String, ConfigVariable> entry : configVariables.entrySet()) {
            ConfigVariable var = entry.getValue();
            if (var.getValue() == null && var.getDefaultValue() != null) {
                userDefinedVariables.put(var.getName(), var.getDefaultValue());
            }
        }
        return userDefinedVariables;
    }
82446
public String expand(Map<String, ?> variables) {
    if (variables == null) {
      throw new IllegalArgumentException("variable map is required.");
    }

    /* resolve all expressions within the template */
    StringBuilder resolved = new StringBuilder();
    for (TemplateChunk chunk : this.templateChunks) {
      if (chunk instanceof Expression) {
        String resolvedExpression = this.resolveExpression((Expression) chunk, variables);
        if (resolvedExpression != null) {
          resolved.append(resolvedExpression);
        }
      } else {
        /* chunk is a literal value */
        resolved.append(chunk.getValue());
      }
    }
    return resolved.toString();
  }
1014878
public String get(String key, String defaultValue) {
		addToDefaults(key, defaultValue);
		String value = get(key);
		if (value == null) {
			return defaultValue;
		} else {
			return value;
		}
	}
1044398
@Nullable
  public Value getLocalVariable(@Nullable final String name) {
    if (name == null) {
      return null;
    }

    final String normalized = assertNotNull(PreprocessorUtils.normalizeVariableName(name));

    if (normalized.isEmpty()) {
      return null;
    }

    return localVarTable.get(normalized);
  }
671900
private static Variable toVariable(final String argument)
   {
      final Variable retVal = new Variable();
      final int equalSignIndex = argument.indexOf('=');

      if (equalSignIndex == -1)
      {
         final String key = argument.substring(2);
         retVal.setKey(key);
      }
      else
      {
         final String key = argument.substring(2, equalSignIndex);
         retVal.setKey(key);
         final String value = argument.substring(equalSignIndex + 1);
         retVal.setValue(value);
      }

      return retVal;
   }
326330
protected void parseBindVariable() {
        String expr = tokenizer.getToken();
        peek().addChild(new BindVariableNode(expr, beanDescFactory));
    }
518089
private VariableStatementTree parseVariableStatement() {
    SourcePosition start = getTreeStartLocation();
    VariableDeclarationListTree declarations = parseVariableDeclarationList();
    eatPossibleImplicitSemiColon();
    return new VariableStatementTree(getTreeLocation(start), declarations);
  }
749897
private void parseVariableDeclaration() {
        Variable var = new Variable();
        var.setName(tokenizer.consume().getContents());
        tokenizer.consumeExpectedSymbol(":");
        var.setValue(parseExpression(true));
        if (tokenizer.current().isSymbol("!") && tokenizer.next().hasContent("default")) {
            var.setDefaultValue(true);
            tokenizer.consume();
            tokenizer.consume();
        }
        result.addVariable(var);
        tokenizer.consumeExpectedSymbol(";");
    }