@Override @SuppressWarnings("unchecked") public void init(SubsetConfiguration conf) { super.init(conf); conf.setListDelimiterHandler(new DefaultListDelimiterHandler(',')); Iterator<String> it = (Iterator<String>) conf.getKeys(); while (it.hasNext()) { String propertyName = it.next(); if (propertyName.startsWith(TAGS_FOR_PREFIX_PROPERTY_PREFIX)) { String contextName = propertyName.substring(TAGS_FOR_PREFIX_PROPERTY_PREFIX.length()); String[] tags = conf.getStringArray(propertyName); boolean useAllTags = false; Set<String> set = new HashSet<>(); for (String tag : tags) { tag = tag.trim(); useAllTags |= tag.equals("*"); if (tag.length() > 0) { set.add(tag); } } if (useAllTags) { set = null; } useTagsMap.put(contextName, set); } } }
@Override public Object escapeList(final List<?> values, final ValueTransformer transformer) { final Object[] escapedValues = new String[values.size()]; int idx = 0; for (final Object v : values) { escapedValues[idx++] = escape(v, transformer); } return StringUtils.join(escapedValues, getDelimiter()); }
@Override protected String escapeString(final String s) { final StringBuilder buf = new StringBuilder(s.length() + BUF_SIZE); for (int i = 0; i < s.length(); i++) { final char c = s.charAt(i); if (c == getDelimiter() || c == ESCAPE) { buf.append(ESCAPE); } buf.append(c); } return buf.toString(); }
if (c != getDelimiter() && c != ESCAPE) if (c == getDelimiter())
((AbstractConfiguration)configuration).setListDelimiterHandler(new DefaultListDelimiterHandler(config.listDelimiter));
Parameters params = new Parameters(); FileBasedConfigurationBuilder<PropertiesConfiguration> builder = new FileBasedConfigurationBuilder<PropertiesConfiguration>( PropertiesConfiguration.class).configure(params.fileBased() .setListDelimiterHandler(new DefaultListDelimiterHandler(',')) .setFile(new File("test.properties"))); PropertiesConfiguration config = builder.getConfiguration(); List<String> linclude = config.getList(String.class, "patternfile.include"); System.out.println(linclude.size()); for(String item: linclude){ System.out.println(item); }
/** * @param resourcePath Path of overlapping properties files * @param classLoader Class loader where the resources are loaded * @return Configuration result * @throws IOException allows IO exceptions. */ public static Configuration loadFromOverlappingResources(String resourcePath, ClassLoader classLoader) throws IOException { Validate.notNull(resourcePath, "Resource path can't be NULL"); Validate.notNull(classLoader, "ClassLoader can't be NULL"); PropertiesConfiguration props = new PropertiesConfiguration(); props.setListDelimiterHandler(new DefaultListDelimiterHandler(',')); Enumeration<URL> resources = classLoader.getResources(resourcePath); while (resources.hasMoreElements()) { InputStream resource = resources.nextElement().openStream(); Reader reader = new InputStreamReader(resource); try { props.read(reader); } catch (ConfigurationException e) { throw new IOException(e); } finally { reader.close(); } } return props; }
private static FileBasedConfiguration createPropertiesConfiguration(Reader reader) throws ConfigurationException, IOException { if (reader == null) { throw new NullPointerException("reader: null"); } FileBasedConfigurationBuilder<FileBasedConfiguration> builder = new FileBasedConfigurationBuilder<FileBasedConfiguration>(PropertiesConfiguration.class) .configure(new Parameters() .properties() .setListDelimiterHandler(new DefaultListDelimiterHandler(','))); FileBasedConfiguration config = builder.getConfiguration(); config.read(reader); return config; }
return new FileBasedConfigurationBuilder<PropertiesConfiguration>(PropertiesConfiguration.class) .configure(new Parameters().properties() .setListDelimiterHandler(new DefaultListDelimiterHandler(',')).setFile(file)) .getConfiguration(); } catch (Exception e) { new FileBasedConfigurationBuilder<PropertiesConfiguration>(PropertiesConfiguration.class) .configure(new Parameters().properties() .setListDelimiterHandler(new DefaultListDelimiterHandler(',')).setURL(xwikiPropertiesUrl)); return builder.getConfiguration(); } else {
Parameters params = new Parameters(); DefaultListDelimiterHandler listDelimiterHandler = new DefaultListDelimiterHandler(CONFIG_LIST_DELIMITER);
/** * Creates application composite configuration. * * @return Application composite configuration. */ private CompositeConfiguration createApplicationConfiguration() { CompositeConfiguration cc = new CompositeConfiguration(); SystemConfiguration systemConfiguration = new SystemConfiguration(); PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); propertiesConfiguration.setThrowExceptionOnMissing(true); propertiesConfiguration.setListDelimiterHandler(new DefaultListDelimiterHandler(';')); propertiesConfiguration.setIncludesAllowed(false); FileLocator locator = FileLocatorUtils.fileLocator() .fileName("testlinkjavaapi.propertiesxml") .create(); propertiesConfiguration.initFileLocator(locator); cc.addConfiguration(systemConfiguration); cc.addConfiguration(propertiesConfiguration); return cc; }
((AbstractConfiguration)configuration).setListDelimiterHandler(new DefaultListDelimiterHandler(config.listDelimiter));
((AbstractConfiguration)configuration).setListDelimiterHandler(new DefaultListDelimiterHandler(config.listDelimiter));