return null;
if (anObject instanceof TemplateModel)
return (TemplateModel) anObject;
-// if (anObject instanceof Date)
-// return new DateAdapter((Date) anObject);
else if (anObject instanceof MessageResources)
return new MessageMethodModel((MessageResources) anObject);
else if (anObject instanceof String)
}
public TemplateModel get(String aKey) throws TemplateModelException {
- if (!valuesCache.containsKey(aKey)) {
- Object value = map.get(aKey);
-
-// ML: this unfortunately doesn't work, because the entity doesn't seem to store
-// fields with null values
-// if (value == null && !map.containsKey(aKey))
-// throw new TemplateModelException("MapAdapter: no key "+aKey+" available");
-
- valuesCache.put(aKey, makeAdapter(value));
- }
-
- return (TemplateModel) valuesCache.get(aKey);
+ try {
+ if (!valuesCache.containsKey(aKey)) {
+ Object value = map.get(aKey);
+
+ if (value == null && !map.containsKey(aKey))
+ throw new TemplateModelException("MapAdapter: no key "+aKey+" available");
+
+ valuesCache.put(aKey, makeAdapter(value));
+ }
+
+ return (TemplateModel) valuesCache.get(aKey);
+ }
+ catch (TemplateModelException e) {
+ throw e;
+ }
+ catch (Throwable t) {
+ throw new TemplateModelException(t.getMessage());
+ }
}
}
position=0;
}
}
-
-/* private static class DateAdapter implements TemplateHashModel {
- Date date;
-
- private DateAdapter(Date aDate) {
- date = aDate;
- }
-
- public boolean isEmpty() {
- return false;
- }
-
- public TemplateModel get(String aKey) throws TemplateModelException {
- return makeAdapter(new SimpleDateFormat(aKey).format(date));
- }
- }
-*/
}