@Test public void testResolveEnvVars() throws EtiqetException { String testString = "$etiqet.directory/extended/path/to/file.ext"; String result = resolveEnvVars(testString); assertFalse(result.contains("${etiqet.directory}")); String etiqetDirectory = System.getProperty("etiqet.directory"); String suffix = "/extended/path/to/file.ext".replaceAll("/", Matcher.quoteReplacement(File.separator)); assertEquals(etiqetDirectory + suffix, result); testString = "${etiqet.directory}"; result = resolveEnvVars(testString); assertFalse(result.contains("${etiqet.directory}")); assertEquals(etiqetDirectory, result); }
public static String resolveEnvVars(String input) throws EtiqetException { String res = null; if (!StringUtils.isNullOrEmpty(input)) { Pattern p = Pattern.compile("\\$\\{([\\w\\.]+)\\}|\\$([\\w\\.]+)"); Matcher m = p.matcher(input); StringBuffer sb = new StringBuffer(); resolveEnvVars(m, sb); res = sb.toString().replace("/", File.separator).trim(); } return res; }
Environment { public static String resolveEnvVars(String input) throws EtiqetException { String res = null; if (!StringUtils.isNullOrEmpty(input)) { Pattern p = Pattern.compile("\\$\\{([\\w\\.]+)\\}|\\$([\\w\\.]+)"); Matcher m = p.matcher(input); StringBuffer sb = new StringBuffer(); resolveEnvVars(m, sb); res = sb.toString().replace("/", File.separator).trim(); } return res; } }
Environment { public static String resolveEnvVars(String input) throws EtiqetException { String res = null; if (!StringUtils.isNullOrEmpty(input)) { Pattern p = Pattern.compile("\\$\\{([\\w\\.]+)\\}|\\$([\\w\\.]+)"); Matcher m = p.matcher(input); StringBuffer sb = new StringBuffer(); resolveEnvVars(m, sb); res = sb.toString().replace("/", File.separator).trim(); } return res; } private  Environment(); }
Environment { public static String resolveEnvVars(String input) throws EtiqetException { String res = null; if (!StringUtils.isNullOrEmpty(input)) { Pattern p = Pattern.compile("\\$\\{([\\w\\.]+)\\}|\\$([\\w\\.]+)"); Matcher m = p.matcher(input); StringBuffer sb = new StringBuffer(); resolveEnvVars(m, sb); res = sb.toString().replace("/", File.separator).trim(); } return res; } private  Environment(); static Boolean isEnvVarSet(String key); static String resolveEnvVars(String input); static InputStream fileResolveEnvVars(String path); }
Environment { public static String resolveEnvVars(String input) throws EtiqetException { String res = null; if (!StringUtils.isNullOrEmpty(input)) { Pattern p = Pattern.compile("\\$\\{([\\w\\.]+)\\}|\\$([\\w\\.]+)"); Matcher m = p.matcher(input); StringBuffer sb = new StringBuffer(); resolveEnvVars(m, sb); res = sb.toString().replace("/", File.separator).trim(); } return res; } private  Environment(); static Boolean isEnvVarSet(String key); static String resolveEnvVars(String input); static InputStream fileResolveEnvVars(String path);  }