/** * Returns the {@link Section} with the given name or {@code null} if no section with that name exists. * * @param sectionName the name of the section to retrieve. * @return the {@link Section} with the given name or {@code null} if no section with that name exists. */ public Section getSection(String sectionName) { String name = cleanName(sectionName); return sections.get(name); }
/** * Removes the section with the specified name and returns it, or {@code null} if the section did not exist. * * @param sectionName the name of the section to remove. * @return the section with the specified name or {@code null} if the section did not exist. */ public Section removeSection(String sectionName) { String name = cleanName(sectionName); return this.sections.remove(name); }
protected static String getSectionName(String line) { String s = StringUtils.clean(line); if (isSectionHeader(s)) { return cleanName(s.substring(1, s.length() - 1)); } return null; }
/** * 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; }
/** * Sets a name/value pair for the section with the given {@code sectionName}. If the section does not yet exist, * it will be created. If the {@code sectionName} is null or empty, the name/value pair will be placed in the * default (unnamed, empty string) section. * * @param sectionName the name of the section to add the name/value pair * @param propertyName the name of the property to add * @param propertyValue the property value */ public void setSectionProperty(String sectionName, String propertyName, String propertyValue) { String name = cleanName(sectionName); Section section = getSection(name); if (section == null) { section = addSection(name); } section.put(propertyName, propertyValue); }
/** * Returns the {@link Section} with the given name or {@code null} if no section with that name exists. * * @param sectionName the name of the section to retrieve. * @return the {@link Section} with the given name or {@code null} if no section with that name exists. */ public Section getSection(String sectionName) { String name = cleanName(sectionName); return sections.get(name); }
/** * Removes the section with the specified name and returns it, or {@code null} if the section did not exist. * * @param sectionName the name of the section to remove. * @return the section with the specified name or {@code null} if the section did not exist. */ public Section removeSection(String sectionName) { String name = cleanName(sectionName); return this.sections.remove(name); }
protected static String getSectionName(String line) { String s = StringUtils.clean(line); if (isSectionHeader(s)) { return cleanName(s.substring(1, s.length() - 1)); } return null; }
/** * 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; }
/** * Sets a name/value pair for the section with the given {@code sectionName}. If the section does not yet exist, * it will be created. If the {@code sectionName} is null or empty, the name/value pair will be placed in the * default (unnamed, empty string) section. * * @param sectionName the name of the section to add the name/value pair * @param propertyName the name of the property to add * @param propertyValue the property value */ public void setSectionProperty(String sectionName, String propertyName, String propertyValue) { String name = cleanName(sectionName); Section section = getSection(name); if (section == null) { section = addSection(name); } section.put(propertyName, propertyValue); }