code: private String replaceVariables(String inString) {
      if (inString == null || inString == "")
        return inString;
      String outString = inString;
  
      // Replace $ENVIRONMENT with the default environment
      outString = stringReplace(outString, "{ENVIRONMENT}", defaultEnvironment);
  
      // Go through the string and try to replace {...} escaped keys
      String currentToken = "";
      String replacedString = "";
      boolean inToken = false;
      for (int i = 0; i < outString.length(); i++) {
        final char currentChar = outString.charAt(i);
        if (!inToken && currentChar != '{') {
          replacedString = replacedString + currentChar;
        } else if (inToken && currentChar == '{') {
          replacedString += "{" + currentToken;
          currentToken = "";
        } else if (inToken && currentChar != '}') {
          currentToken = currentToken + currentChar;
        } else if (inToken && currentChar == '}') {
          // Try to find a replacement
          inToken = false;
          String replacement = null;
          if (singletonInstance != null) {
            replacement = PropertyManager.getProperty("", currentToken, null);
          }
          if (replacement != null) {
            replacedString += replacement;
          } else {
            replacedString += "{" + currentToken + "}";
          }
          currentToken = "";
        } else if (!inToken && currentChar == '{') {
          inToken = true;
          currentToken = "";
        }
      }
      if (!currentToken.equals("")) {
        replacedString += "{" + currentToken;
      }
      outString = replacedString;
  
      // If in == out, then we've done as many replacements as we can, we're done
      if (outString.equals(inString)) {
        // Finally, check to see if the string should be clarified
        if (inString.startsWith("[[[") && inString.endsWith("]]]")) {
          // Clarify...
          final String obfuscatedText = inString.substring(3, inString.length() - 3);
          inString = ObfuscationManager.clarify(obfuscatedText);
        }
        return inString;
      }
      return replaceVariables(outString);
    }
docs: Replaces variables like {ENVIRONMENT} with their correct values, also
  handles clarifying obfuscated strings in the form
  KEY=[[[xxxxxxxxxxxxxxxx]]]