*/
public static String makeURLArg(Object arg) { // TODO: Move method?
Map<Object, String> map = ThreadContext.get().getCachedPropertyValues();
String s = "";
if (arg instanceof Persistable) {
Persistable persistable = (Persistable) arg;
if (map.containsKey(persistable)) {
s = map.get(persistable);
} else {
Class<? extends Persistable> persistableClass = ThreadContext
.getWebSite().getQuerier().getBaseType(persistable);
Method method = findQueryMethod(persistableClass);
if (method != null) {
String name = method.getName();
try {
// Prefer calling the getter method to use cache if
// possible
name = name.substring(3);
String getterName = "get" + name;
Method getterMethod = persistableClass
.getMethod(getterName);
s = getterMethod.invoke(persistable).toString();
} catch (Exception e) {
name = name.substring(3, 4).toLowerCase()
+ name.substring(4);
s = ThreadContext
.getWebSite()
.getQuerier()
.getPropertyFromId(persistableClass, name,
persistable.getId());
}
map.put(persistable, s);
} else {
s = persistable.getId().toString();
}
}
} else if (arg != null) {
s = arg.toString();
} else {