/** * Ends the configuration building. * @throws ConfigurationException if not all opened sections have been closed. */ public void endConfiguration() throws ConfigurationException { // Makes sure currentSection is the root section. if(!sections.empty()) throw new ConfigurationStructureException("Not all sections have been closed."); sections = null; sectionNames = null; }
/** * Ends the current section. * @param name name of the section that's being closed. * @throws ConfigurationException if we're not closing a legal section. */ public void endSection(String name) throws ConfigurationException { ConfigurationSection buffer; // Makes sure there is a section to close. try { buffer = sections.pop(); sectionNames.pop(); } catch(EmptyStackException e) {throw new ConfigurationStructureException("Section " + name + " was already closed.");} // Makes sure we're closing the right section. if(buffer.getSection(name) != currentSection) throw new ConfigurationStructureException("Section " + name + " is not the currently opened section."); currentSection = buffer; }