/** this renames data values in the global datafile. */
private void remapDataNames(String oldPrefix, String newPrefix) {
String name, newName;
DataElement element;
SaveableData value;
oldPrefix = oldPrefix + "/";
newPrefix = newPrefix + "/";
int oldPrefixLen = oldPrefix.length();
Iterator k = getInternalKeys();
while (k.hasNext()) {
name = (String) k.next();
if (!name.startsWith(oldPrefix))
continue;
element = (DataElement) data.get(name);
if (element == null ||
element.isDefaultName() ||
element.datafile == null ||
element.datafile.prefix == null ||
element.datafile.prefix.length() > 0)
// only remap data which lives in the global datafile.
continue;
value = element.getValue();
// At this point, we will not rename data elements unless they
// are SimpleData. Non-simple data (e.g., functions, etc) needs
// to know its name and prefix, so it would be more complicated to
// move - but none of that stuff should be moving.
if (value instanceof SimpleData) {
newName = newPrefix + name.substring(oldPrefixLen);
newName = intern(newName, false);
//System.out.println("renaming " + name + " to " + newName);
putValue(newName, value.getSimpleValue(), IS_NOT_DEFAULT_VAL);
putValue(name, null, IS_NOT_DEFAULT_VAL);
}
}
}