this(name, name, null, null); }
public PathVariable(String name, String metaName, String impliedPath,
String defaultValue) {
this.metaName = metaName;
SaveableData val = null;
DataRepository data = getDataRepository();
if (name.startsWith("/")) {
// The name is absolute - look it up in the data repository.
val = data.getSimpleValue(dataName = name);
} else {
// Look for an inheritable value with this name in the data
// repository.
StringBuffer prefix = new StringBuffer(getPrefix());
val = data.getInheritableValue(prefix, name);
if (val != null && !(val instanceof SimpleData))
val = val.getSimpleValue();
dataName = data.createDataName(prefix.toString(), name);
}
// Check to see if a value was POSTed to this CGI script for this
// data element. If so, it would override any previous value.
String postedValue = getParameter(name);
if (postedValue != null) {
value = postedValue;
if (pathStartsWith(value, impliedPath)) {
// the user supplied an absolute path. Rewrite it so it
// is relative to the impliedPath.
value = value.substring(impliedPath.length());
if (value.startsWith(File.separator))
value = value.substring(1);
}
if (! pathEqual(value, defaultValue) || val != null) {
// Save this user-specified value in the repository.
// (Default values are not saved to the repository.)
data.userPutValue(dataName, StringData.create(value));
}
} else if (val instanceof SimpleData)
value = ((SimpleData) val).format();