Mercurial Hosting > nabble
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:7ecd1a4ef557 |
---|---|
1 package nabble.view.web.template; | |
2 | |
3 import nabble.naml.compiler.Interpreter; | |
4 import nabble.model.Site; | |
5 | |
6 | |
7 public class NamespaceUtils { | |
8 | |
9 public static int getInt(Interpreter interp, String attributeName, String errorMessage) { | |
10 return getInt(interp, attributeName, null, errorMessage); | |
11 } | |
12 | |
13 public static int getInt(Interpreter interp, String attributeName, Integer defaultValue, String errorMessage) { | |
14 String value = interp.getArgString(attributeName); | |
15 if (value == null && defaultValue != null) | |
16 return defaultValue; | |
17 try { | |
18 return Integer.valueOf(value.trim()); | |
19 } catch(NumberFormatException e) { | |
20 throw new RuntimeException(errorMessage,e); | |
21 } | |
22 } | |
23 | |
24 } |