private InputStream getHelpStream(Class c, String suffix) { Locale locale = Stapler.getCurrentRequest().getLocale(); String base = c.getName().replace('.', '/').replace('$', '/') + "/help" + suffix; ClassLoader cl = c.getClassLoader(); if (cl == null) return null; InputStream in; in = cl.getResourceAsStream( base + '_' + locale.getLanguage() + '_' + locale.getCountry() + '_' + locale.getVariant() + ".html"); if (in != null) return in; in = cl.getResourceAsStream( base + '_' + locale.getLanguage() + '_' + locale.getCountry() + ".html"); if (in != null) return in; in = cl.getResourceAsStream(base + '_' + locale.getLanguage() + ".html"); if (in != null) return in; // default return cl.getResourceAsStream(base + ".html"); }
private String getViewPage(Class<?> clazz, String pageName, String defaultValue) { while (clazz != Object.class) { String name = clazz.getName().replace('.', '/').replace('$', '/') + "/" + pageName; if (clazz.getClassLoader().getResource(name) != null) return '/' + name; clazz = clazz.getSuperclass(); } return defaultValue; }