[stringtemplate-interest] Fail on undefined property

Felix Dorner felix_do at web.de
Fri Jul 31 02:04:44 PDT 2009


Hi,

I'm accessing properties of a Properties object in my template. I need to fail generation if a requested property isn't defined (but StringTemplate happily inserts the empty String in such cases.

What I did is to subclass Properties so that it throws a runtime exception upon its get() method on undefined properties. However, I see that you also make use of containsKey(), so I'd need to override that too, and I'm starting to feel that my approach is probably not the right way to go. Isn't there an option that tells StringTemplate to fail if an attribute is not defined?


Thanks,
Felix


More information about the stringtemplate-interest mailing list