/* (non-Javadoc)
@see org.osgi.service.upnp.UPnPAction#getStateVariable(java.lang.String)
174473
public UPnPStateVariable getStateVariable(String argumentName) {
		if (argumentName.equals("NewTime")) return time;
		else if (argumentName.equals("Result")) return result;
		else return null;
	}
54080
public com.google.protobuf.ByteString
      getVariableNameBytes() {
    java.lang.Object ref = variableName_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      variableName_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }
340544
@Override
	public Parameter getParam(final String paramName) {
		Parameter param = getBindParameter(paramName);
		if (param == null) {
			Map<String, Parameter> constParams = getConstParameterMap();
			if (constParams != null) {
				param = constParams.get(paramName.toUpperCase());
			}
		}
		return param;
	}
413683
public com.google.api.ads.admanager.axis.v201811.CreativeTemplateVariable[] getVariables() {
        return variables;
    }
726741
public final Variable getVariable(int variableNum) {
    int index = getVariableIndex(variableNum);
    if (index >= 0) {
      return vars[index];
    } else {
      return null;
    }
  }
1014492
@Override
    public Map<String, String> getUserDefinedVariables() {
        HashMap<String, String> userDefinedVariables = new HashMap<String, String>();
        for (Map.Entry<String, ConfigVariable> entry : configVariables.entrySet()) {
            ConfigVariable var = entry.getValue();
            if (var.getValue() != null) {
                userDefinedVariables.put(var.getName(), var.getValue());
            }
        }
        for (CommandLineVariable clVar : commandLineVariables) {
            userDefinedVariables.put(clVar.getName(), clVar.getValue());
        }
        return userDefinedVariables;
    }
152554
public ValueExpression resolveVariable(String variable)
    {
        ValueExpression ve = null;
        try
        {
            if (_vars != null)
            {
                ve = (ValueExpression) _vars.get(variable);

                // Is this code in a block that wants to cache 
                // the resulting expression(s) and variable has been resolved?
                if (_trackResolveVariables && ve != null)
                {
                    _variableResolved = true;
                }
            }
            
            if (ve == null)
            {
                return _target.resolveVariable(variable);
            }
            
            return ve;
        }
        catch (StackOverflowError e)
        {
            throw new ELException("Could not Resolve Variable [Overflow]: " + variable, e);
        }
    }
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;
    }
102953
public Object resolveVariable(String pName) throws ELException {
		ELContext ctx = this.getELContext();
		return ctx.getELResolver().getValue(ctx, null, pName);
	}
1242770
public String getVariableShortName(VariableElement var) {
    String baseName = getVariableBaseName(var);
    if (var.getKind().isField() && !ElementUtil.isGlobalVar(var)) {
      return baseName + '_';
    }
    return baseName;
  }
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;
    }
  }
864013
function getVariable(variable) {

  if ( cached.data == null ) {
    getData();
  }

  if (variable.toUpperCase() in cached.data ) {
    return cached.data[variable.toUpperCase()];
  } else if (variable in cached.data) {
    return cached.data[variable];
  }
}
1240895
public String getVariableAsString(String name) {
        TraceState ts = traceState.get();

        if (ts != null) {
            Object variable = ts.getVariables().get(name);
            if (log.isLoggable(Level.FINEST)) {
                log.finest("Get variable '" + name + "' = " + variable);
            }
            return variable == null ? null : variable.toString();
        }

        if (log.isLoggable(Level.FINEST)) {
            log.finest("Get variable '" + name + "' requested, but no trace state");
        }
        return null;
    }
1105871
@Override
	protected List<String> getVariablesToIgnore() {

		List<String> variablesToIgnore = new ArrayList<> ();
		variablesToIgnore.add( "^" + Pattern.quote( MILLI_TIME ) + "$" );
		variablesToIgnore.add( "^" + Pattern.quote( NANO_TIME ) + "$" );
		variablesToIgnore.add( "^" + Pattern.quote( SMART_INDEX ) + "$" );
		variablesToIgnore.add( "^" + Pattern.quote( RANDOM_UUID ) + "$" );

		for( String var : this.context.variables.keySet())
			variablesToIgnore.add( "^\\$\\(" + Pattern.quote( var ) + "\\)$" );

		variablesToIgnore.add( "^" + Pattern.quote( FORMATTED_TIME_PREFIX ) + "[^)]*\\)$" );
		variablesToIgnore.add( "^" + Pattern.quote( EXISTING_INDEX_PREFIX ) + "[^)]*\\)$" );
		return variablesToIgnore;
	}


	/**
	 * Extracts the date pattern for a "formatted time" variable.
	 * @param group a formatted time
	 * @return a non-null string
	 */
	static String extractDatePattern( String group ) {
		return group.substring( FORMATTED_TIME_PREFIX.length(), group.length() - 2 ).trim();
	}


	/**
	 * Replaces variables in instance names.
	 * @param value an expression that can reference other variables (not null)
	 * @param context a context (not null)
	 * @param parentInstancePath the parent instance path (may be null)
	 * @param context a non-null map with context information
	 * @return the updated value, or null if an <code>$(existing_index ...)</code> variable failed to be resolved
	 */
	static String replaceVariables( String value, Context context, String parentInstancePath ) {

		long nanoTime = System.nanoTime();
		long milliTime = TimeUnit.MILLISECONDS.convert( nanoTime, TimeUnit.NANOSECONDS );

		// Simple replacements
		value = value.replace( NANO_TIME, String.valueOf( nanoTime ));
		value = value.replace( MILLI_TIME, String.valueOf( milliTime ));
		value = value.replace( RANDOM_UUID, UUID.randomUUID().toString());

		// A little more complex
		if( value.startsWith( FORMATTED_TIME_PREFIX )
				&& value.endsWith( ")" )) {

			String datePattern = extractDatePattern( value );
			SimpleDateFormat sdf = new SimpleDateFormat( datePattern );

			// We replace the whole value as such variables were validated and span over a entire line
			value = sdf.format( new Date( milliTime ));
		}

		// Even more complex
		int smartCpt = 0;
		if( value.contains( SMART_INDEX )) {
			for( int cpt = 1; smartCpt == 0; cpt++ ) {
				String testName = value.replace( SMART_INDEX, String.valueOf( cpt ));
				String testPath = "/" + testName;
				if( parentInstancePath != null )
					testPath = parentInstancePath + testPath;

				if( ! context.instanceExists( testPath )) {
					smartCpt = cpt;
				}
			}
		}

		value = value.replace( SMART_INDEX, String.valueOf( smartCpt ));

		// To perform in last: deal with existing indexes
		boolean disabled = false;
		Pattern fullPattern = Pattern.compile( EXISTING_INDEX_PATTERN );
		Matcher m = fullPattern.matcher( value );
		if( value.contains( EXISTING_INDEX_PREFIX )
				&& m.matches()) {

			String minOrMax = m.group( 2 );
			String prefix = m.group( 1 );
			String suffix = m.group( 6 );
			String bound = m.group( 5 );
			String instanceNamePattern = "/" + prefix + "(\\d+)" + suffix;
			if( parentInstancePath != null )
				instanceNamePattern = parentInstancePath + instanceNamePattern;

			// Find the index
			int cpt = findIndex( instanceNamePattern, context, bound, "MIN".equals( minOrMax ));

			// If cpt is negative, do not replace anything, nothing matches the requirements.
			// We just return null for the variable's value.
			if( cpt < 0 )
				disabled = true;
			else
				value = m.replaceAll( "$1" + String.valueOf( cpt ) + "$6" );
		}

		// Disabled variable => return null
		if( disabled )
			value = null;

		// Inject other variables, if necessary.
		// Disabled variables are contagious, this is managed during the parsing.
		else
			value = CommandsParser.injectContextVariables( value, context.variables );

		return value;
	}


	/**
	 * @param instanceNamePattern
	 * @param context
	 * @param bound
	 * @param findMinimum true to get the minimum value, false for the maximum
	 * @return -1 if no matching instance was found, a positive integer otherwise
	 */
	private static int findIndex( String instanceNamePattern, Context context, String bound, boolean findMinimum ) {

		// Find all the matching indexes?
		Pattern pattern = Pattern.compile( instanceNamePattern );
		SortedSet<Integer> foundIndexes = new TreeSet<> ();
		for( String instancePath : context.instancePathToComponentName.keySet()) {
			Matcher m = pattern.matcher( instancePath );
			if( ! m .find())
				continue;

			int index = Integer.parseInt( m.group( 1 ));
			foundIndexes.add( index );
		}

		// Exclude indexes that are out of bound
		if( bound != null ) {
			bound = bound.trim();
			int min = 0, max = Integer.MAX_VALUE;
			int value = Integer.parseInt( bound.substring( 1 ).trim());
			if( '<' == bound.charAt( 0 ))
				max = value;
			else
				min = value;

			Set<Integer> toRemove = new HashSet<> ();
			for( Integer index : foundIndexes ) {
				if( index <= min || index >= max )
					toRemove.add( index );
			}

			foundIndexes.removeAll( toRemove );
		}

		// Eventually, decide whether we want the tail or the head
		int result;
		if( foundIndexes.isEmpty())
			result = -1;
		else if( findMinimum )
			result = foundIndexes.first();
		else
			result = foundIndexes.last();

		return result;
	}
610405
public java.util.Map<String, String> getVariables() {
        if (variables == null) {
            variables = new com.amazonaws.internal.SdkInternalMap<String, String>();
        }
        return variables;
    }
1200986
private CustomVariable getCustomVariable(String parameter, int index){        
        CustomVariableList cvl = (CustomVariableList)parameters.get(parameter);
        if (cvl == null){
            return null;
        }
        
        return cvl.get(index);
    }
142339
public final int getVariableByName(String variableName) {
    int index = getVariableIndex(variableName);
    if (index == -1) {
      return index;
    } else {
      return nums[index];
    }
  }