/** * Create a list from values. * * @param values values to create a list from. * @return list with values. */ public static <T> List<T> li(T... values) { return list(values); }
/** * Provide names of headers to log to the log system with each request. * This configuration is dynamic and can be changed during runtime. * * @param headerNames list of headers to log. If the first argument is '*', all headers will be logged. */ public static void logHeaders(String... headerNames) { logHeaders = list(headerNames); }
/** * Create a list from values. * * @param values values to create a list from. * @return list with values. */ public static <T> List<T> li(T... values) { return list(values); }
@Override public List<String> getEnds() { return list("</#if>"); }
/** * Create a list from values. * * @param values values to create a list from. * @return list with values. */ public static <T> List<T> li(T... values) { return list(values); }
@Override public List<String> getEnds() { return list("}"); }
@Override public List<String> getEnds() { return list("</#list>"); }
public List<String> getEnds() { return list("</@" + tagName + ">", "/>"); }
/** * @param interfaceClass class of an interface for Guice injector */ public DynamicBuilder bind(Class interfaceClass){ pairs.add(list(interfaceClass)); return this; }
void setIncludedActions(String[] includedActions) { wildcard = false; this.includedActions.addAll(Collections.list(includedActions)); }
final void setExcludedActions(String[] excludedActions) { this.excludedActions.addAll(Collections.list(excludedActions)); }
/** * Adds a set of filters to a set of controllers. * The filters are invoked in the order specified. Will reject adding the same instance of a filter more than once. * * @param filters filters to be added. * @return object with <code>to()</code> method which accepts a controller class. */ protected FilterBuilder add(HttpSupportFilter... filters) { for (HttpSupportFilter filter : filters) { if(allFilters.contains(filter)){ throw new IllegalArgumentException("Cannot register the same filter instance more than once."); } } allFilters.addAll(Collections.list(filters)); return new FilterBuilder(filters); }
protected synchronized static String compileClass(String className) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { String controllerFileName = className.replace(".", System.getProperty("file.separator")) + ".java"; URLClassLoader loader = ((URLClassLoader) Thread.currentThread().getContextClassLoader()); URL[] urls = loader.getURLs(); String classpath = getClasspath(urls); StringWriter writer = new StringWriter(); PrintWriter out = new PrintWriter(writer); String targetClasses = join(list("target", "classes"), System.getProperty("file.separator")); String srcMainJava = join(list("src", "main", "java"), System.getProperty("file.separator")); String[] args = {"-g:lines,source,vars", "-d", targetClasses, "-cp", classpath, srcMainJava + System.getProperty("file.separator") + controllerFileName}; Class cl = Class.forName("com.sun.tools.javac.Main"); Method compile = cl.getMethod("compile", String[].class, PrintWriter.class); compile.invoke(null, args, out); out.flush(); return writer.toString(); }
/** * Returns multiple request values for a name. * * @param name name of multiple values from request. * @return multiple request values for a name. */ public static List<String> params(String name){ String[] values = RequestContext.getHttpRequest().getParameterValues(name); List<String>valuesList = null; if (name.equals("id")) { if(values.length == 1){ valuesList = Collections.singletonList(values[0]); }else if(values.length > 1){ valuesList = asList(values); } } else { valuesList = values == null? new ArrayList<String>() : list(values); String userSegment = RequestContext.getRequestVo().getUserSegments().get(name); if(userSegment != null){ valuesList.add(userSegment); } } return valuesList; }