/** * Display the configuration for debugging purposes to System.out. */ public void display() { Iterator i = getKeys(); while (i.hasNext()) { String key = (String) i.next(); Object value = get(key); System.out.println(key + " => " + value); } }
/** * Get the list of the keys contained in the configuration * repository that match the specified prefix. * * @param prefix the prefix to match * @return an Iterator of keys that match the prefix */ public Iterator getKeys(String prefix) { Iterator keys = getKeys(); ArrayList matchingKeys = new ArrayList(); while (keys.hasNext()) { Object key = keys.next(); if (key instanceof String && ((String) key).startsWith(prefix)) { matchingKeys.add(key); } } return matchingKeys.iterator(); }
/** * Combines an existing Hashtable with this Hashtable. * <p> * Warning: It will overwrite previous entries without warning. * * @param props the properties to combine */ public void combine(ExtProperties props) { for (Iterator it = props.getKeys(); it.hasNext();) { String key = (String) it.next(); setProperty(key, props.get(key)); } }
Iterator keys = getKeys(); boolean validSubset = false;
protected void readData(ExtProperties dataset) { if (dataset != null) { for (Iterator i = dataset.getKeys(); i.hasNext(); ) { String key = (String)i.next(); // if it contains a period, it can't be a context key; // it must be a data property. ignore it for now. if (key.indexOf('.') >= 0) { continue; } Data data = new Data(); data.setKey(key); data.setValue(dataset.getString(key)); // get/set the type/converter properties ExtProperties props = dataset.subset(key); setProperties(props, data); addData(data); } } }
protected void readProperties(ExtProperties configProps, Configuration config) { ExtProperties properties = configProps.subset("property"); if (properties != null) { for (Iterator i = properties.getKeys(); i.hasNext(); ) { String name = (String)i.next(); String value = properties.getString(name); ExtProperties propProps = properties.subset(name); if (propProps.size() == 1) { // then set this as a 'simple' property config.setProperty(name, value); } else { // add it as a convertable property Property property = new Property(); property.setName(name); property.setValue(value); // set the type/converter properties setProperties(propProps, property); } } } }