/** * Sets the value of a property for this listener * * @param propertyName The name of the property to set * @param value The value to associated with the property */ public void set(String propertyName, Object value) { if (value == null) { // Delete the property if (thePropertyNames == null) return; int idx = ArrayUtils.indexOf(thePropertyNames, propertyName); if (idx < 0) return; if (thePropertyNames.length == 1) { thePropertyNames = null; thePropertyValues = null; } else { thePropertyNames = ArrayUtils.remove(thePropertyNames, idx); thePropertyValues = ArrayUtils.remove(thePropertyValues, idx); } } else if (thePropertyNames == null) { thePropertyNames = new String[] {propertyName}; thePropertyValues = new Object[] {value}; } else { int idx = ArrayUtils.indexOf(thePropertyNames, propertyName); if (idx < 0) { thePropertyNames = ArrayUtils.add(thePropertyNames, propertyName); thePropertyValues = ArrayUtils.add(thePropertyValues, value); } else thePropertyValues[idx] = value; } }
/** * @param listener The listener to be notified when this configuration or any of its children * change */ public void addListener(ConfigListener listener) { if (listener != null) theListeners = prisms.util.ArrayUtils.add(theListeners, listener); }
/** * @param sub The sub configuration to add to this configuration * @return The added config, for chaining */ public MutableConfig addSubConfig(MutableConfig sub) { theSubConfigs = prisms.util.ArrayUtils.add(theSubConfigs, sub); sub.theParent = this; sub.addListener(theSubConfigListener); return sub; }