Mercurial Hosting > nabble
view src/nabble/view/web/template/NamespaceUtils.java @ 0:7ecd1a4ef557
add content
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 21 Mar 2019 19:15:52 -0600 |
parents | |
children |
line wrap: on
line source
package nabble.view.web.template; import nabble.naml.compiler.Interpreter; import nabble.model.Site; public class NamespaceUtils { public static int getInt(Interpreter interp, String attributeName, String errorMessage) { return getInt(interp, attributeName, null, errorMessage); } public static int getInt(Interpreter interp, String attributeName, Integer defaultValue, String errorMessage) { String value = interp.getArgString(attributeName); if (value == null && defaultValue != null) return defaultValue; try { return Integer.valueOf(value.trim()); } catch(NumberFormatException e) { throw new RuntimeException(errorMessage,e); } } }