src/java/de/uapcore/lightpit/Functions.java

changeset 13
f4608ad6c947
parent 11
737ab27e37b3
child 24
8137ec335416
equal deleted inserted replaced
12:005d27918b57 13:f4608ad6c947
27 * 27 *
28 */ 28 */
29 package de.uapcore.lightpit; 29 package de.uapcore.lightpit;
30 30
31 import java.util.Optional; 31 import java.util.Optional;
32 import javax.servlet.ServletContext;
32 import javax.servlet.http.HttpServletRequest; 33 import javax.servlet.http.HttpServletRequest;
33 import org.slf4j.Logger; 34 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory; 35 import org.slf4j.LoggerFactory;
35 36
36 /** 37 /**
38 */ 39 */
39 public final class Functions { 40 public final class Functions {
40 41
41 private static final Logger LOG = LoggerFactory.getLogger(Functions.class); 42 private static final Logger LOG = LoggerFactory.getLogger(Functions.class);
42 43
44 public static Optional<String[]> availableLanguages(ServletContext ctx) {
45 return Optional.ofNullable(ctx.getInitParameter(Constants.CTX_ATTR_LANGUAGES)).map((x) -> x.split("\\s*,\\s*"));
46 }
47
48 public static String enforceExt(String filename, String ext) {
49 return filename.endsWith(ext) ? filename : filename + ext;
50 }
51
43 public static String jspPath(String filename) { 52 public static String jspPath(String filename) {
44 return Constants.JSP_PATH_PREFIX + filename; 53 return enforceExt(Constants.JSP_PATH_PREFIX + filename, ".jsp");
54 }
55
56 public static String jspfPath(String filename) {
57 return enforceExt(Constants.JSPF_PATH_PREFIX + filename, ".jspf");
58 }
59
60 public static String dynFragmentPath(String filename) {
61 return enforceExt(Constants.DYN_FRAGMENT_PATH_PREFIX + filename, ".jsp");
45 } 62 }
46 63
47 public static String fqn(String base, String name) { 64 public static String fqn(String base, String name) {
48 return base+"."+name; 65 return base+"."+name;
49 } 66 }

mercurial