@Test void loadBadSectionFile() throws IOException { String filename = "bad-section.txt"; assertThrows(IllegalArgumentException.class, () -> { AdditionalBuildCommands.load(getPath(filename)); }); }
public static AdditionalBuildCommands load(Path file) throws IOException { logger.entering(file); AdditionalBuildCommands result = new AdditionalBuildCommands(); result.contents = new HashMap<>(); try (BufferedReader reader = Files.newBufferedReader(file)) { List<String> buffer = new ArrayList<>(); String currentSection = null; String line; while ((line = reader.readLine()) != null) { logger.finest(line); String sectionStart = result.checkForSectionHeader(line); if (currentSection != null && sectionStart == null) { buffer.add(line); } else if (currentSection != null) { logger.fine("IMG-0015", buffer.size(), currentSection); result.contents.put(currentSection, buffer); buffer = new ArrayList<>(); currentSection = sectionStart; } else if (sectionStart != null) { currentSection = sectionStart; } } if (currentSection != null && !buffer.isEmpty()) { logger.fine("IMG-0015", buffer.size(), currentSection); result.contents.put(currentSection, buffer); } } catch (IOException ioe) { logger.severe("IMG-0013", file.getFileName()); throw ioe; } logger.exiting(); return result; }
AdditionalBuildCommands { public static AdditionalBuildCommands load(Path file) throws IOException { logger.entering(file); AdditionalBuildCommands result = new AdditionalBuildCommands(); result.contents = new HashMap<>(); try (BufferedReader reader = Files.newBufferedReader(file)) { List<String> buffer = new ArrayList<>(); String currentSection = null; String line; while ((line = reader.readLine()) != null) { logger.finest(line); String sectionStart = result.checkForSectionHeader(line); if (currentSection != null && sectionStart == null) { buffer.add(line); } else if (currentSection != null) { logger.fine("IMG-0015", buffer.size(), currentSection); result.contents.put(currentSection, buffer); buffer = new ArrayList<>(); currentSection = sectionStart; } else if (sectionStart != null) { currentSection = sectionStart; } } if (currentSection != null && !buffer.isEmpty()) { logger.fine("IMG-0015", buffer.size(), currentSection); result.contents.put(currentSection, buffer); } } catch (IOException ioe) { logger.severe("IMG-0013", file.getFileName()); throw ioe; } logger.exiting(); return result; } }
AdditionalBuildCommands { public static AdditionalBuildCommands load(Path file) throws IOException { logger.entering(file); AdditionalBuildCommands result = new AdditionalBuildCommands(); result.contents = new HashMap<>(); try (BufferedReader reader = Files.newBufferedReader(file)) { List<String> buffer = new ArrayList<>(); String currentSection = null; String line; while ((line = reader.readLine()) != null) { logger.finest(line); String sectionStart = result.checkForSectionHeader(line); if (currentSection != null && sectionStart == null) { buffer.add(line); } else if (currentSection != null) { logger.fine("IMG-0015", buffer.size(), currentSection); result.contents.put(currentSection, buffer); buffer = new ArrayList<>(); currentSection = sectionStart; } else if (sectionStart != null) { currentSection = sectionStart; } } if (currentSection != null && !buffer.isEmpty()) { logger.fine("IMG-0015", buffer.size(), currentSection); result.contents.put(currentSection, buffer); } } catch (IOException ioe) { logger.severe("IMG-0013", file.getFileName()); throw ioe; } logger.exiting(); return result; } private  AdditionalBuildCommands(); }
AdditionalBuildCommands { public static AdditionalBuildCommands load(Path file) throws IOException { logger.entering(file); AdditionalBuildCommands result = new AdditionalBuildCommands(); result.contents = new HashMap<>(); try (BufferedReader reader = Files.newBufferedReader(file)) { List<String> buffer = new ArrayList<>(); String currentSection = null; String line; while ((line = reader.readLine()) != null) { logger.finest(line); String sectionStart = result.checkForSectionHeader(line); if (currentSection != null && sectionStart == null) { buffer.add(line); } else if (currentSection != null) { logger.fine("IMG-0015", buffer.size(), currentSection); result.contents.put(currentSection, buffer); buffer = new ArrayList<>(); currentSection = sectionStart; } else if (sectionStart != null) { currentSection = sectionStart; } } if (currentSection != null && !buffer.isEmpty()) { logger.fine("IMG-0015", buffer.size(), currentSection); result.contents.put(currentSection, buffer); } } catch (IOException ioe) { logger.severe("IMG-0013", file.getFileName()); throw ioe; } logger.exiting(); return result; } private  AdditionalBuildCommands(); int size(); Map<String,List<String>> getContents(); List<String> getSection(String name); static AdditionalBuildCommands load(Path file); String validSectionNames(); }
AdditionalBuildCommands { public static AdditionalBuildCommands load(Path file) throws IOException { logger.entering(file); AdditionalBuildCommands result = new AdditionalBuildCommands(); result.contents = new HashMap<>(); try (BufferedReader reader = Files.newBufferedReader(file)) { List<String> buffer = new ArrayList<>(); String currentSection = null; String line; while ((line = reader.readLine()) != null) { logger.finest(line); String sectionStart = result.checkForSectionHeader(line); if (currentSection != null && sectionStart == null) { buffer.add(line); } else if (currentSection != null) { logger.fine("IMG-0015", buffer.size(), currentSection); result.contents.put(currentSection, buffer); buffer = new ArrayList<>(); currentSection = sectionStart; } else if (sectionStart != null) { currentSection = sectionStart; } } if (currentSection != null && !buffer.isEmpty()) { logger.fine("IMG-0015", buffer.size(), currentSection); result.contents.put(currentSection, buffer); } } catch (IOException ioe) { logger.severe("IMG-0013", file.getFileName()); throw ioe; } logger.exiting(); return result; } private  AdditionalBuildCommands(); int size(); Map<String,List<String>> getContents(); List<String> getSection(String name); static AdditionalBuildCommands load(Path file); String validSectionNames(); static final String BEFORE_JDK; static final String AFTER_JDK; static final String BEFORE_FMW; static final String AFTER_FMW; static final String BEFORE_WDT; static final String AFTER_WDT; static final String FINAL_BLD; }