private void addSection(String name, StringBuilder content) { if (content.length() > 0) { String contentString = content.toString(); String cleaned = StringUtils.clean(contentString); if (cleaned != null) { Section section = new Section(name, contentString); if (!section.isEmpty()) { sections.put(name, section); } } } }
/** * Creates a new {@code Ini} instance with the specified defaults. * * @param defaults the default sections and/or key-value pairs to copy into the new instance. */ public Ini(Ini defaults) { this(); if (defaults == null) { throw new NullPointerException("Defaults cannot be null."); } for (Section section : defaults.getSections()) { Section copy = new Section(section); this.sections.put(section.getName(), copy); } }
/** * Ensures a section with the specified name exists, adding a new one if it does not yet exist. * * @param sectionName the name of the section to ensure existence * @return the section created if it did not yet exist, or the existing Section that already existed. */ public Section addSection(String sectionName) { String name = cleanName(sectionName); Section section = getSection(name); if (section == null) { section = new Section(name); this.sections.put(name, section); } return section; }
/** * Ensures a section with the specified name exists, adding a new one if it does not yet exist. * * @param sectionName the name of the section to ensure existence * @return the section created if it did not yet exist, or the existing Section that already existed. */ public Section addSection(String sectionName) { String name = cleanName(sectionName); Section section = getSection(name); if (section == null) { section = new Section(name); this.sections.put(name, section); } return section; }
/** * Creates a new {@code Ini} instance with the specified defaults. * * @param defaults the default sections and/or key-value pairs to copy into the new instance. */ public Ini(Ini defaults) { this(); if (defaults == null) { throw new NullPointerException("Defaults cannot be null."); } for (Section section : defaults.getSections()) { Section copy = new Section(section); this.sections.put(section.getName(), copy); } }
private void addSection(String name, StringBuilder content) { if (content.length() > 0) { String contentString = content.toString(); String cleaned = StringUtils.clean(contentString); if (cleaned != null) { Section section = new Section(name, contentString); if (!section.isEmpty()) { sections.put(name, section); } } } }