@Test public void testRichIni_valuesWithSpaces2() throws Exception { String path = getClass().getResource("workflow_fromPDE_1444_1.ini").getPath(); Map<String, Map<String, String>> hm = new HashMap<>(); MapTools.ini2RichMap(path, hm); Assert.assertTrue("ini2RichMap with spaced values2 failed", hm.size() == 4); Assert.assertTrue( "white spaced value2 for ini2RichMap failed", hm.get("novoalign_index").size() == 2 && hm.get("novoalign_index") .get("default_value") .equals("-d ${workflow_bundle_dir}/bundle_GenomicAlignmentNovoalign/0.9.2/data/indexes/novoalign/hg19/hg19_random/hg19_random.nix")); Assert.assertTrue("white spaced value2 defaults for ini2RichMap failed", hm.get("novoalign_index").size() == 2 && hm.get("novoalign_index").get("key").equals("novoalign_index")); }
public static void ini2RichMap(String iniFile, Map<String, Map<String, String>> hm) { HashMap<String, String> detailsMap = null; try { BufferedReader br = new BufferedReader(new FileReader(new File(iniFile))); String line; while ((line = br.readLine()) != null) { if (line.startsWith("#") && line.matches("^#\\s*key=.*$")) { detailsMap = new HashMap<>(); line = line.replaceAll("#\\s*", ""); String[] kvs = line.split(":"); for (String pair : kvs) { String[] kv = pair.split("="); if (kv.length == 2) detailsMap.put(kv[0], kv[1]); else detailsMap.put(kv[0], ""); } } else if (isLineMatchesKeyValue(line)) { String[] kv = line.split("\\s*=\\s*"); if (detailsMap == null || !kv[0].equals(detailsMap.get("key"))) { detailsMap = new HashMap<>(); detailsMap.put("key", kv[0]); } if (kv.length == 1) { detailsMap.put("default_value", ""); } else { detailsMap.put("default_value", kv[1]); } hm.put(kv[0], detailsMap); } } } catch (Exception e) { throw rethrow(e); } }
MapTools { public static void ini2RichMap(String iniFile, Map<String, Map<String, String>> hm) { HashMap<String, String> detailsMap = null; try { BufferedReader br = new BufferedReader(new FileReader(new File(iniFile))); String line; while ((line = br.readLine()) != null) { if (line.startsWith("#") && line.matches("^#\\s*key=.*$")) { detailsMap = new HashMap<>(); line = line.replaceAll("#\\s*", ""); String[] kvs = line.split(":"); for (String pair : kvs) { String[] kv = pair.split("="); if (kv.length == 2) detailsMap.put(kv[0], kv[1]); else detailsMap.put(kv[0], ""); } } else if (isLineMatchesKeyValue(line)) { String[] kv = line.split("\\s*=\\s*"); if (detailsMap == null || !kv[0].equals(detailsMap.get("key"))) { detailsMap = new HashMap<>(); detailsMap.put("key", kv[0]); } if (kv.length == 1) { detailsMap.put("default_value", ""); } else { detailsMap.put("default_value", kv[1]); } hm.put(kv[0], detailsMap); } } } catch (Exception e) { throw rethrow(e); } } }
MapTools { public static void ini2RichMap(String iniFile, Map<String, Map<String, String>> hm) { HashMap<String, String> detailsMap = null; try { BufferedReader br = new BufferedReader(new FileReader(new File(iniFile))); String line; while ((line = br.readLine()) != null) { if (line.startsWith("#") && line.matches("^#\\s*key=.*$")) { detailsMap = new HashMap<>(); line = line.replaceAll("#\\s*", ""); String[] kvs = line.split(":"); for (String pair : kvs) { String[] kv = pair.split("="); if (kv.length == 2) detailsMap.put(kv[0], kv[1]); else detailsMap.put(kv[0], ""); } } else if (isLineMatchesKeyValue(line)) { String[] kv = line.split("\\s*=\\s*"); if (detailsMap == null || !kv[0].equals(detailsMap.get("key"))) { detailsMap = new HashMap<>(); detailsMap.put("key", kv[0]); } if (kv.length == 1) { detailsMap.put("default_value", ""); } else { detailsMap.put("default_value", kv[1]); } hm.put(kv[0], detailsMap); } } } catch (Exception e) { throw rethrow(e); } }  }
MapTools { public static void ini2RichMap(String iniFile, Map<String, Map<String, String>> hm) { HashMap<String, String> detailsMap = null; try { BufferedReader br = new BufferedReader(new FileReader(new File(iniFile))); String line; while ((line = br.readLine()) != null) { if (line.startsWith("#") && line.matches("^#\\s*key=.*$")) { detailsMap = new HashMap<>(); line = line.replaceAll("#\\s*", ""); String[] kvs = line.split(":"); for (String pair : kvs) { String[] kv = pair.split("="); if (kv.length == 2) detailsMap.put(kv[0], kv[1]); else detailsMap.put(kv[0], ""); } } else if (isLineMatchesKeyValue(line)) { String[] kv = line.split("\\s*=\\s*"); if (detailsMap == null || !kv[0].equals(detailsMap.get("key"))) { detailsMap = new HashMap<>(); detailsMap.put("key", kv[0]); } if (kv.length == 1) { detailsMap.put("default_value", ""); } else { detailsMap.put("default_value", kv[1]); } hm.put(kv[0], detailsMap); } } } catch (Exception e) { throw rethrow(e); } }  static void ini2Map(String iniFile, Map<String, String> hm); static void ini2RichMap(String iniFile, Map<String, Map<String, String>> hm); static void ini2Map(String iniFile, Map<String, String> hm, boolean keyToUpper); static void ini2Map(InputStream iniFile, Map<String, String> hm, boolean keyToUpper); static void cli2Map(String[] args, Map<String, String> hm); static Map mapString2Int(Map map); static void provideBundleVersion(Map<String, String> m, String bundleVersion); static void provideBundleDir(Map<String, String> m, String bundleDir); static Map<String, String> providedMap(String bundleDir, String bundleSeqwareVersion); static String generatedValue(String key); static Map<String, String> expandVariables(Map<String, String> raw); static Map<String, String> expandVariables(Map<String, String> raw, Map<String, String> provided); static Map<String, String> expandVariables(Map<String, String> raw, Map<String, String> provided, boolean allowMissingVars); static Map<String, String> iniString2Map(String iniString); static SortedSet<WorkflowRunParam> createWorkflowRunParameters(HashMap<String, String> map); }
MapTools { public static void ini2RichMap(String iniFile, Map<String, Map<String, String>> hm) { HashMap<String, String> detailsMap = null; try { BufferedReader br = new BufferedReader(new FileReader(new File(iniFile))); String line; while ((line = br.readLine()) != null) { if (line.startsWith("#") && line.matches("^#\\s*key=.*$")) { detailsMap = new HashMap<>(); line = line.replaceAll("#\\s*", ""); String[] kvs = line.split(":"); for (String pair : kvs) { String[] kv = pair.split("="); if (kv.length == 2) detailsMap.put(kv[0], kv[1]); else detailsMap.put(kv[0], ""); } } else if (isLineMatchesKeyValue(line)) { String[] kv = line.split("\\s*=\\s*"); if (detailsMap == null || !kv[0].equals(detailsMap.get("key"))) { detailsMap = new HashMap<>(); detailsMap.put("key", kv[0]); } if (kv.length == 1) { detailsMap.put("default_value", ""); } else { detailsMap.put("default_value", kv[1]); } hm.put(kv[0], detailsMap); } } } catch (Exception e) { throw rethrow(e); } }  static void ini2Map(String iniFile, Map<String, String> hm); static void ini2RichMap(String iniFile, Map<String, Map<String, String>> hm); static void ini2Map(String iniFile, Map<String, String> hm, boolean keyToUpper); static void ini2Map(InputStream iniFile, Map<String, String> hm, boolean keyToUpper); static void cli2Map(String[] args, Map<String, String> hm); static Map mapString2Int(Map map); static void provideBundleVersion(Map<String, String> m, String bundleVersion); static void provideBundleDir(Map<String, String> m, String bundleDir); static Map<String, String> providedMap(String bundleDir, String bundleSeqwareVersion); static String generatedValue(String key); static Map<String, String> expandVariables(Map<String, String> raw); static Map<String, String> expandVariables(Map<String, String> raw, Map<String, String> provided); static Map<String, String> expandVariables(Map<String, String> raw, Map<String, String> provided, boolean allowMissingVars); static Map<String, String> iniString2Map(String iniString); static SortedSet<WorkflowRunParam> createWorkflowRunParameters(HashMap<String, String> map); static final String VAR_RANDOM; static final String VAR_DATE; static final String VAR_DATETIME; static final String VAR_TIMESTAMP; static final String VAR_UUID; static final String VAR_BUNDLE_DIR; static final String LEGACY_VAR_RANDOM; static final String LEGACY_VAR_DATE; static final String LEGACY_VAR_BUNDLE_DIR; static final String VAR_WORKFLOW_VERSION; }