public void setOptions(Map ops) {
if (ops == null)
throw new IllegalArgumentException("The options must not be null."); //$NON-NLS-1$
Properties newOptions = new Properties();
for (Iterator entries = ops.entrySet().iterator(); entries.hasNext();) {
Entry entry = (Entry) entries.next();
if (!(entry.getKey() instanceof String) || !(entry.getValue() instanceof String))
throw new IllegalArgumentException("Option keys and values must be of type String: " + entry.getKey() + "=" + entry.getValue()); //$NON-NLS-1$ //$NON-NLS-2$
newOptions.put(entry.getKey(), ((String) entry.getValue()).trim());
}
Set fireChangesTo = null;
synchronized (lock) {
if (options == null) {
disabledOptions = newOptions;
// no events to fire
return;
}
fireChangesTo = new HashSet();
// first check for removals
for (Iterator keys = options.keySet().iterator(); keys.hasNext();) {
String key = (String) keys.next();
if (!newOptions.containsKey(key)) {
String symbolicName = getSymbolicName(key);
if (symbolicName != null)
fireChangesTo.add(symbolicName);
}
}
// now check for changes to existing values
for (Iterator newEntries = newOptions.entrySet().iterator(); newEntries.hasNext();) {
Entry entry = (Entry) newEntries.next();
String existingValue = (String) options.get(entry.getKey());
if (!entry.getValue().equals(existingValue)) {
String symbolicName = getSymbolicName((String) entry.getKey());
if (symbolicName != null)
fireChangesTo.add(symbolicName);
}
}
// finally set the actual options