@Test public void testParser() { BootFeaturesInstaller installer = new BootFeaturesInstaller(null, null, new String[0], "", false); Assert.assertEquals(asList(setOf("test1", "test2"), setOf("test3")), installer.parseBootFeatures(" ( test1 , test2 ) , test3 ")); Assert.assertEquals(Collections.singletonList(setOf("test1", "test2", "test3")), installer.parseBootFeatures(" test1 , test2, test3")); Assert.assertEquals(asList(setOf("test1"), setOf("test2"), setOf("test3")), installer.parseBootFeatures("(test1), (test2), test3")); }
protected List<Set<String>> parseBootFeatures(String bootFeatures) { List<Set<String>> stages = new ArrayList<>(); StringTokenizer tokenizer = new StringTokenizer(bootFeatures, " \t\r\n,()", true); int paren = 0; Set<String> stage = new LinkedHashSet<>(); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); if (token.equals("(")) { if (paren == 0) { if (!stage.isEmpty()) { stages.add(stage); stage = new LinkedHashSet<>(); } paren++; } else { throw new IllegalArgumentException("Bad syntax in boot features: '" + bootFeatures + "'"); } } else if (token.equals(")")) { if (paren == 1) { if (!stage.isEmpty()) { stages.add(stage); stage = new LinkedHashSet<>(); } paren--; } else { throw new IllegalArgumentException("Bad syntax in boot features: '" + bootFeatures + "'"); } } else if (!token.matches("[ \t\r\n]+|,")) { stage.add(token); } } if (!stage.isEmpty()) { stages.add(stage); } return stages; }
BootFeaturesInstaller { protected List<Set<String>> parseBootFeatures(String bootFeatures) { List<Set<String>> stages = new ArrayList<>(); StringTokenizer tokenizer = new StringTokenizer(bootFeatures, " \t\r\n,()", true); int paren = 0; Set<String> stage = new LinkedHashSet<>(); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); if (token.equals("(")) { if (paren == 0) { if (!stage.isEmpty()) { stages.add(stage); stage = new LinkedHashSet<>(); } paren++; } else { throw new IllegalArgumentException("Bad syntax in boot features: '" + bootFeatures + "'"); } } else if (token.equals(")")) { if (paren == 1) { if (!stage.isEmpty()) { stages.add(stage); stage = new LinkedHashSet<>(); } paren--; } else { throw new IllegalArgumentException("Bad syntax in boot features: '" + bootFeatures + "'"); } } else if (!token.matches("[ \t\r\n]+|,")) { stage.add(token); } } if (!stage.isEmpty()) { stages.add(stage); } return stages; } }
BootFeaturesInstaller { protected List<Set<String>> parseBootFeatures(String bootFeatures) { List<Set<String>> stages = new ArrayList<>(); StringTokenizer tokenizer = new StringTokenizer(bootFeatures, " \t\r\n,()", true); int paren = 0; Set<String> stage = new LinkedHashSet<>(); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); if (token.equals("(")) { if (paren == 0) { if (!stage.isEmpty()) { stages.add(stage); stage = new LinkedHashSet<>(); } paren++; } else { throw new IllegalArgumentException("Bad syntax in boot features: '" + bootFeatures + "'"); } } else if (token.equals(")")) { if (paren == 1) { if (!stage.isEmpty()) { stages.add(stage); stage = new LinkedHashSet<>(); } paren--; } else { throw new IllegalArgumentException("Bad syntax in boot features: '" + bootFeatures + "'"); } } else if (!token.matches("[ \t\r\n]+|,")) { stage.add(token); } } if (!stage.isEmpty()) { stages.add(stage); } return stages; } BootFeaturesInstaller(BundleContext bundleContext,
                                 FeaturesServiceImpl featuresService,
                                 String[] repositories,
                                 String features,
                                 boolean asynchronous); }
BootFeaturesInstaller { protected List<Set<String>> parseBootFeatures(String bootFeatures) { List<Set<String>> stages = new ArrayList<>(); StringTokenizer tokenizer = new StringTokenizer(bootFeatures, " \t\r\n,()", true); int paren = 0; Set<String> stage = new LinkedHashSet<>(); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); if (token.equals("(")) { if (paren == 0) { if (!stage.isEmpty()) { stages.add(stage); stage = new LinkedHashSet<>(); } paren++; } else { throw new IllegalArgumentException("Bad syntax in boot features: '" + bootFeatures + "'"); } } else if (token.equals(")")) { if (paren == 1) { if (!stage.isEmpty()) { stages.add(stage); stage = new LinkedHashSet<>(); } paren--; } else { throw new IllegalArgumentException("Bad syntax in boot features: '" + bootFeatures + "'"); } } else if (!token.matches("[ \t\r\n]+|,")) { stage.add(token); } } if (!stage.isEmpty()) { stages.add(stage); } return stages; } BootFeaturesInstaller(BundleContext bundleContext,
                                 FeaturesServiceImpl featuresService,
                                 String[] repositories,
                                 String features,
                                 boolean asynchronous); void start(); }
BootFeaturesInstaller { protected List<Set<String>> parseBootFeatures(String bootFeatures) { List<Set<String>> stages = new ArrayList<>(); StringTokenizer tokenizer = new StringTokenizer(bootFeatures, " \t\r\n,()", true); int paren = 0; Set<String> stage = new LinkedHashSet<>(); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); if (token.equals("(")) { if (paren == 0) { if (!stage.isEmpty()) { stages.add(stage); stage = new LinkedHashSet<>(); } paren++; } else { throw new IllegalArgumentException("Bad syntax in boot features: '" + bootFeatures + "'"); } } else if (token.equals(")")) { if (paren == 1) { if (!stage.isEmpty()) { stages.add(stage); stage = new LinkedHashSet<>(); } paren--; } else { throw new IllegalArgumentException("Bad syntax in boot features: '" + bootFeatures + "'"); } } else if (!token.matches("[ \t\r\n]+|,")) { stage.add(token); } } if (!stage.isEmpty()) { stages.add(stage); } return stages; } BootFeaturesInstaller(BundleContext bundleContext,
                                 FeaturesServiceImpl featuresService,
                                 String[] repositories,
                                 String features,
                                 boolean asynchronous); void start();  }