view src/nabble/view/web/template/NamespaceUtils.java @ 62:4674ed7d56df default tip

remove n2
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 30 Sep 2023 20:25:29 -0600
parents 7ecd1a4ef557
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);
		}
	}

}