public static void writeFunctions(Map<String, String> functionsToWrite, OsFamily osFamily, StringBuilder builder) { if (functionsToWrite.size() > 0) { builder.append(ShellToken.BEGIN_FUNCTIONS.to(osFamily)); for (String function : functionsToWrite.values()) { builder.append(Utils.replaceTokens(function, ShellToken.tokenValueMap(osFamily))); } builder.append(ShellToken.END_FUNCTIONS.to(osFamily)); } }
public static String escapeVarTokens(String toEscape, OsFamily family) { Map<String, String> inputToEscape = Maps.newHashMap(); for (ShellToken token : ImmutableList.of(ShellToken.VARL, ShellToken.VARR)) { if (!token.to(family).equals("")) { String tokenS = "{" + token.toString().toLowerCase() + "}"; inputToEscape.put(tokenS, "{escvar}" + tokenS); } } for (Entry<String, String> entry : inputToEscape.entrySet()) { toEscape = toEscape.replace(entry.getKey(), entry.getValue()); } return toEscape; }
@Override public String apply(String input) { String variableNameKey = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, input) + "Variable"; if (ShellToken.tokenValueMap(family).containsKey(variableNameKey)) return ShellToken.tokenValueMap(family).get(variableNameKey); return input; } }
@Override public String apply(String input) { String variableNameKey = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, input) + "Variable"; if (ShellToken.tokenValueMap(family).containsKey(variableNameKey)) return ShellToken.tokenValueMap(family).get(variableNameKey); return input; } }
public static String escapeVarTokens(String toEscape, OsFamily family) { Map<String, String> inputToEscape = Maps.newHashMap(); for (ShellToken token : ImmutableList.of(ShellToken.VARL, ShellToken.VARR)) { if (!token.to(family).equals("")) { String tokenS = "{" + token.toString().toLowerCase() + "}"; inputToEscape.put(tokenS, "{escvar}" + tokenS); } } for (Entry<String, String> entry : inputToEscape.entrySet()) { toEscape = toEscape.replace(entry.getKey(), entry.getValue()); } return toEscape; }
public static void writeFunctions(Map<String, String> functionsToWrite, OsFamily osFamily, StringBuilder builder) { if (!functionsToWrite.isEmpty()) { builder.append(ShellToken.BEGIN_FUNCTIONS.to(osFamily)); for (String function : functionsToWrite.values()) { builder.append(Utils.replaceTokens(function, ShellToken.tokenValueMap(osFamily))); } builder.append(ShellToken.END_FUNCTIONS.to(osFamily)); } }
@Override public String apply(String input) { String variableNameKey = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, input) + "Variable"; if (ShellToken.tokenValueMap(family).containsKey(variableNameKey)) return ShellToken.tokenValueMap(family).get(variableNameKey); return input; } }
public static String escapeVarTokens(String toEscape, OsFamily family) { Map<String, String> inputToEscape = Maps.newHashMap(); for (ShellToken token : ImmutableList.of(ShellToken.VARL, ShellToken.VARR)) { if (!token.to(family).equals("")) { String tokenS = "{" + token.toString().toLowerCase() + "}"; inputToEscape.put(tokenS, "{escvar}" + tokenS); } } for (Entry<String, String> entry : inputToEscape.entrySet()) { toEscape = toEscape.replace(entry.getKey(), entry.getValue()); } return toEscape; }
public static void writeFunctions(Map<String, String> functionsToWrite, OsFamily osFamily, StringBuilder builder) { if (functionsToWrite.size() > 0) { builder.append(ShellToken.BEGIN_FUNCTIONS.to(osFamily)); for (String function : functionsToWrite.values()) { builder.append(Utils.replaceTokens(function, ShellToken.tokenValueMap(osFamily))); } builder.append(ShellToken.END_FUNCTIONS.to(osFamily)); } }
@Override public String apply(String input) { String variableNameKey = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, input) + "Variable"; if (ShellToken.tokenValueMap(family).containsKey(variableNameKey)) return ShellToken.tokenValueMap(family).get(variableNameKey); return input; } }
public static String escapeVarTokens(String toEscape, OsFamily family) { Map<String, String> inputToEscape = Maps.newHashMap(); for (ShellToken token : ImmutableList.of(ShellToken.VARL, ShellToken.VARR)) { if (!token.to(family).equals("")) { String tokenS = "{" + token.toString().toLowerCase() + "}"; inputToEscape.put(tokenS, "{escvar}" + tokenS); } } for (Entry<String, String> entry : inputToEscape.entrySet()) { toEscape = toEscape.replace(entry.getKey(), entry.getValue()); } return toEscape; }
protected String appendLineToWindowsFile(String line, String path) { String quote = ""; if (!ShellToken.VQ.to(OsFamily.WINDOWS).equals("")) { quote = "'"; } else { line = escapeVarTokens(line, OsFamily.WINDOWS); } return String.format("echo %s%s%s >>%s{lf}", quote, line, quote, path); }
public static void writeFunctions(Map<String, String> functionsToWrite, OsFamily osFamily, StringBuilder builder) { if (functionsToWrite.size() > 0) { builder.append(ShellToken.BEGIN_FUNCTIONS.to(osFamily)); for (String function : functionsToWrite.values()) { builder.append(Utils.replaceTokens(function, ShellToken.tokenValueMap(osFamily))); } builder.append(ShellToken.END_FUNCTIONS.to(osFamily)); } }