List of usage examples for org.apache.commons.configuration PropertyConverter toIterator
public static Iterator toIterator(Object value, char delimiter)
From source file:com.netflix.config.ConcurrentMapConfiguration.java
/** * Adds the specified value for the given property. This method supports * single values and containers (e.g. collections or arrays) as well. In the * latter case, {@link #addPropertyDirect(String, Object)} will be called for each * element.//from w ww . j ava 2 s.co m * * @param key the property key * @param value the value object * @param delimiter the list delimiter character */ private void addPropertyValues(String key, Object value, char delimiter) { Iterator it = PropertyConverter.toIterator(value, delimiter); while (it.hasNext()) { addPropertyDirect(key, it.next()); } }
From source file:at.salzburgresearch.kmt.zkconfig.ZookeeperConfiguration.java
@Override public void addProperty(String key, Object value) { fireEvent(EVENT_ADD_PROPERTY, key, value, true); final Object prevValue = getProperty(key); if (prevValue == null) { setPropertyDirect(key, value);//www . java2s .c om } else { final List<Object> list; if (prevValue instanceof List) { @SuppressWarnings("unchecked") final List<Object> _l = (List<Object>) prevValue; list = _l; } else { list = new ArrayList<>(); list.add(prevValue); } Iterator<?> it = PropertyConverter.toIterator(value, isDelimiterParsingDisabled() ? '\0' : getListDelimiter()); while (it.hasNext()) { list.add(it.next()); } setPropertyDirect(key, list); } fireEvent(EVENT_ADD_PROPERTY, key, value, false); }
From source file:com.netflix.config.ConcurrentMapConfiguration.java
protected void setPropertyImpl(String key, Object value) { if (isDelimiterParsingDisabled()) { map.put(key, value);// w w w .ja v a 2s .c o m } else if ((value instanceof String) && ((String) value).indexOf(getListDelimiter()) < 0) { map.put(key, value); } else { Iterator it = PropertyConverter.toIterator(value, getListDelimiter()); List<Object> list = new CopyOnWriteArrayList<Object>(); while (it.hasNext()) { list.add(it.next()); } if (list.size() == 1) { map.put(key, list.get(0)); } else { map.put(key, list); } } }