public PippoRuntimeException(Throwable cause, String message, Object... args) { super(StringUtils.format(message, args), cause); }
public PippoRuntimeException(String message, Object... args) { super(StringUtils.format(message, args)); }
public static String getPippoLogo() { return StringUtils.format(PIPPO_LOGO, getPippoVersion()); }
public void error(String message, Object... args) { add(Message.ERROR, StringUtils.format(message, args)); }
public void warning(String message, Object... args) { add(Message.WARNING, StringUtils.format(message, args)); }
public void info(String message, Object... args) { add(Message.INFO, StringUtils.format(message, args)); }
public void success(String message, Object... args) { add(Message.SUCCESS, StringUtils.format(message, args)); }
/** * Replaces '{}' in the format string with the supplied arguments and * writes the string content directly to the response. * <p>This method commits the response.</p> * * @param format * @param args */ public void send(String format, Object... args) { checkCommitted(); commit(StringUtils.format(format, args)); }
protected String generateDefaultDirectoryListing(RouteContext routeContext, File dir, String absoluteDirUri) { StringBuilder sb = new StringBuilder(); sb.append("<html><body><table>"); SimpleDateFormat df = new SimpleDateFormat(timestampPattern); NumberFormat nf = new DecimalFormat(fileSizePattern); for (DirEntry dirEntry : getDirEntries(routeContext, dir, absoluteDirUri)) { sb.append(StringUtils.format("<tr><td><a href=\"{}\">{}</a></td><td>{}</td><td>{}</td></tr>\n", dirEntry.getUrl(), dirEntry.getName(), dirEntry.isFile() ? nf.format(dirEntry.getSize()) : "", df.format(dirEntry.getLastModified()))); } sb.append("</table></body></html>"); return sb.toString(); }
protected void processRouteInterceptors(RouteContext routeContext) { if (interceptors.isEmpty()) { return; } List<RouteMatch> chain = new ArrayList<>(); for (RouteHandler interceptor : interceptors) { // create a route for interceptor Route route = new Route(routeContext.getRequestMethod(), routeContext.getRequestUri(), interceptor); route.setName(StringUtils.format("{}<{}>", Interceptor.class.getSimpleName(), route.getRouteHandler().getClass().getSimpleName())); route.bindAll(routeContext.getRoute().getAttributes()); // add route in chain RouteMatch match = new RouteMatch(route, null); chain.add(match); } // TODO DefaultRouteContext is hardcoded RouteContext context = new DefaultRouteContext(routeContext.getApplication(), routeContext.getRequest(), routeContext.getResponse(), chain); context.next(); }
public String getUriPattern() { if (contentTypeSuffixes == null || contentTypeSuffixes.isEmpty()) { return uriPattern; } // appends a content-type suffix expression String suffixExpression = StringUtils.format("(\\.({}))", Joiner.on("|").join(contentTypeSuffixes)); if (!contentTypeSuffixesRequired) { // content-type suffix is optional suffixExpression += '?'; } return uriPattern + suffixExpression; }
public String getUriPattern() { if (contentTypeSuffixes == null || contentTypeSuffixes.isEmpty()) { return uriPattern; } // appends a content-type suffix expression String suffixExpression = StringUtils.format("(\\.({}))", Joiner.on("|").join(contentTypeSuffixes)); if (!contentTypeSuffixesRequired) { // content-type suffix is optional suffixExpression += '?'; } return uriPattern + suffixExpression; }
protected void processRouteInterceptors(Context context) { if (routeInterceptors.isEmpty()) { return; } List<RouteMatch> chain = new ArrayList<>(); for (RouteHandler<Context> interceptor : routeInterceptors) { Route route = new Route(context.getRequestMethod(), context.getRequestUri(), interceptor); route.setName(StringUtils.format("{}<{}>", RouteInterceptor.class.getSimpleName(), route.getRouteHandler().getClass().getSimpleName())); RouteMatch match = new RouteMatch(route, null); chain.add(match); } Context subContext = new Context(context, chain); subContext.next(); }
protected void processRouteInterceptors(Context context) { if (routeInterceptors.isEmpty()) { return; } List<RouteMatch> chain = new ArrayList<>(); for (RouteHandler<Context> interceptor : routeInterceptors) { Route route = new Route(context.getRequestMethod(), context.getRequestUri(), interceptor); route.setName(StringUtils.format("{}<{}>", RouteInterceptor.class.getSimpleName(), route.getRouteHandler().getClass().getSimpleName())); RouteMatch match = new RouteMatch(route, null); chain.add(match); } Context subContext = new Context(context, chain); subContext.next(); }
protected void processRouteInterceptors(RouteContext routeContext) { if (interceptors.isEmpty()) { return; } List<RouteMatch> chain = new ArrayList<>(); for (RouteHandler interceptor : interceptors) { // create a route for interceptor Route route = new Route(routeContext.getRequestMethod(), routeContext.getRequestUri(), interceptor); route.setName(StringUtils.format("{}<{}>", Interceptor.class.getSimpleName(), route.getRouteHandler().getClass().getSimpleName())); route.bindAll(routeContext.getRoute().getAttributes()); // add route in chain RouteMatch match = new RouteMatch(route, null); chain.add(match); } // TODO DefaultRouteContext is hardcoded RouteContext context = new DefaultRouteContext(routeContext.getApplication(), routeContext.getRequest(), routeContext.getResponse(), chain); context.next(); }