/** * Returns {@code true} if no sections have been configured, or if there are sections, but the sections themselves * are all empty, {@code false} otherwise. * * @return {@code true} if no sections have been configured, or if there are sections, but the sections themselves * are all empty, {@code false} otherwise. */ public boolean isEmpty() { Collection<Section> sections = this.sections.values(); if (!sections.isEmpty()) { for (Section section : sections) { if (!section.isEmpty()) { return false; } } } return true; }
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); } } } }
private static String toString(String name, Ini.Section mapping) { if(mapping == null || mapping.isEmpty()) { return ""; } Joiner kvJoiner = Joiner.on(" = "); List<String> lines = Lists.newArrayList(); lines.add(NL); lines.add("[" + name + "]"); for(String key : mapping.keySet()) { lines.add(kvJoiner.join(key, mapping.get(key))); } return Joiner.on(NL).join(lines); }
/** * Returns {@code true} if no sections have been configured, or if there are sections, but the sections themselves * are all empty, {@code false} otherwise. * * @return {@code true} if no sections have been configured, or if there are sections, but the sections themselves * are all empty, {@code false} otherwise. */ public boolean isEmpty() { Collection<Section> sections = this.sections.values(); if (!sections.isEmpty()) { for (Section section : sections) { if (!section.isEmpty()) { return false; } } } return true; }
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); } } } }
protected void applyFilterChainResolver(Ini ini, Map<String, ?> defaults) { if (ini == null || ini.isEmpty()) { //nothing to use to create the resolver, just return //(the AbstractShiroFilter allows a null resolver, in which case the original FilterChain is // always used). return; } //only create a resolver if the 'filters' or 'urls' sections are defined: Ini.Section urls = ini.getSection(IniFilterChainResolverFactory.URLS); Ini.Section filters = ini.getSection(IniFilterChainResolverFactory.FILTERS); if ((urls != null && !urls.isEmpty()) || (filters != null && !filters.isEmpty())) { //either the urls section or the filters section was defined. Go ahead and create the resolver //and set it: IniFilterChainResolverFactory filterChainResolverFactory = new IniFilterChainResolverFactory(ini, defaults); filterChainResolverFactory.setFilterConfig(getFilterConfig()); FilterChainResolver resolver = filterChainResolverFactory.getInstance(); setFilterChainResolver(resolver); } }