/** * Constructor. * * @param mediaType The resource media type. * @param headers The HTTP response headers for this streamed resource. * @param cached * Identifies if this resource is cached in memory. * <br>If <jk>true</jk>, the contents will be loaded into a String for fast retrieval. * @param contents * The resource contents. * <br>If multiple contents are specified, the results will be concatenated. * <br>Contents can be any of the following: * <ul> * <li><code>InputStream</code> * <li><code>Reader</code> - Converted to UTF-8 bytes. * <li><code>File</code> * <li><code>CharSequence</code> - Converted to UTF-8 bytes. * </ul> * @throws IOException */ public ReaderResource(MediaType mediaType, Map<String,Object> headers, boolean cached, Object...contents) throws IOException { this.mediaType = mediaType; this.headers = immutableMap(headers); this.contents = cached ? new Object[]{readAll(contents)} : contents; }
/** * Constructor. * * @param mediaType The resource media type. * @param headers The HTTP response headers for this streamed resource. * @param cached * Identifies if this stream resource is cached in memory. * <br>If <jk>true</jk>, the contents will be loaded into a byte array for fast retrieval. * @param contents * The resource contents. * <br>If multiple contents are specified, the results will be concatenated. * <br>Contents can be any of the following: * <ul> * <li><code><jk>byte</jk>[]</code> * <li><code>InputStream</code> * <li><code>Reader</code> - Converted to UTF-8 bytes. * <li><code>File</code> * <li><code>CharSequence</code> - Converted to UTF-8 bytes. * </ul> * @throws IOException */ public StreamResource(MediaType mediaType, Map<String,Object> headers, boolean cached, Object...contents) throws IOException { this.mediaType = mediaType; this.headers = immutableMap(headers); this.contents = cached ? new Object[]{readBytes(contents)} : contents; }
/** * Constructor. * * @param mediaType The resource media type. * @param headers The HTTP response headers for this streamed resource. * @param cached * Identifies if this resource is cached in memory. * <br>If <jk>true</jk>, the contents will be loaded into a String for fast retrieval. * @param contents * The resource contents. * <br>If multiple contents are specified, the results will be concatenated. * <br>Contents can be any of the following: * <ul> * <li><code>InputStream</code> * <li><code>Reader</code> - Converted to UTF-8 bytes. * <li><code>File</code> * <li><code>CharSequence</code> - Converted to UTF-8 bytes. * </ul> * @throws IOException */ public ReaderResource(MediaType mediaType, Map<String,Object> headers, boolean cached, Object...contents) throws IOException { this.mediaType = mediaType; this.headers = immutableMap(headers); this.contents = cached ? new Object[]{readAll(contents)} : contents; }
/** * Constructor. * * @param mediaType The resource media type. * @param headers The HTTP response headers for this streamed resource. * @param cached * Identifies if this resource is cached in memory. * <br>If <jk>true</jk>, the contents will be loaded into a String for fast retrieval. * @param contents * The resource contents. * <br>If multiple contents are specified, the results will be concatenated. * <br>Contents can be any of the following: * <ul> * <li><code>InputStream</code> * <li><code>Reader</code> - Converted to UTF-8 bytes. * <li><code>File</code> * <li><code>CharSequence</code> - Converted to UTF-8 bytes. * </ul> * @throws IOException */ public ReaderResource(MediaType mediaType, Map<String,Object> headers, boolean cached, Object...contents) throws IOException { this.mediaType = mediaType; this.headers = immutableMap(headers); this.contents = cached ? new Object[]{readAll(contents)} : contents; }
/** * Constructor. * * @param mediaType The resource media type. * @param headers The HTTP response headers for this streamed resource. * @param cached * Identifies if this stream resource is cached in memory. * <br>If <jk>true</jk>, the contents will be loaded into a byte array for fast retrieval. * @param contents * The resource contents. * <br>If multiple contents are specified, the results will be concatenated. * <br>Contents can be any of the following: * <ul> * <li><code><jk>byte</jk>[]</code> * <li><code>InputStream</code> * <li><code>Reader</code> - Converted to UTF-8 bytes. * <li><code>File</code> * <li><code>CharSequence</code> - Converted to UTF-8 bytes. * </ul> * @throws IOException */ public StreamResource(MediaType mediaType, Map<String,Object> headers, boolean cached, Object...contents) throws IOException { this.mediaType = mediaType; this.headers = immutableMap(headers); this.contents = cached ? new Object[]{readBytes(contents)} : contents; }
/** * Constructor. * * @param mediaType The resource media type. * @param headers The HTTP response headers for this streamed resource. * @param cached * Identifies if this stream resource is cached in memory. * <br>If <jk>true</jk>, the contents will be loaded into a byte array for fast retrieval. * @param contents * The resource contents. * <br>If multiple contents are specified, the results will be concatenated. * <br>Contents can be any of the following: * <ul> * <li><code><jk>byte</jk>[]</code> * <li><code>InputStream</code> * <li><code>Reader</code> - Converted to UTF-8 bytes. * <li><code>File</code> * <li><code>CharSequence</code> - Converted to UTF-8 bytes. * </ul> * @throws IOException */ public StreamResource(MediaType mediaType, Map<String,Object> headers, boolean cached, Object...contents) throws IOException { this.mediaType = mediaType; this.headers = immutableMap(headers); this.contents = cached ? new Object[]{readBytes(contents)} : contents; }
/** * Constructor. * * @param resourceClass * The resource/servlet class which serves as the base location of the location below. * @param path * The mapped URI path. * <br>Leading and trailing slashes are trimmed. * @param location * The location relative to the resource class. * <br>Leading and trailing slashes are trimmed. * @param responseHeaders * The response headers. * Can be <jk>null</jk>. */ public StaticFileMapping(Class<?> resourceClass, String path, String location, Map<String,Object> responseHeaders) { this.resourceClass = resourceClass; this.path = StringUtils.trimSlashes(path); this.location = StringUtils.trimSlashes(location); this.responseHeaders = immutableMap(responseHeaders); }
/** * Constructor. * * @param resourceClass * The resource/servlet class which serves as the base location of the location below. * @param path * The mapped URI path. * <br>Leading and trailing slashes are trimmed. * @param location * The location relative to the resource class. * <br>Leading and trailing slashes are trimmed. * @param responseHeaders * The response headers. * Can be <jk>null</jk>. */ public StaticFileMapping(Class<?> resourceClass, String path, String location, Map<String,Object> responseHeaders) { this.resourceClass = resourceClass; this.path = StringUtils.trimSlashes(path); this.location = StringUtils.trimSlashes(location); this.responseHeaders = immutableMap(responseHeaders); }
/** * Constructor. * * @param resourceClass * The resource/servlet class which serves as the base location of the location below. * @param path * The mapped URI path. * <br>Leading and trailing slashes are trimmed. * @param location * The location relative to the resource class. * <br>Leading and trailing slashes are trimmed. * @param responseHeaders * The response headers. * Can be <jk>null</jk>. */ public StaticFileMapping(Class<?> resourceClass, String path, String location, Map<String,Object> responseHeaders) { this.resourceClass = resourceClass; this.path = StringUtils.trimSlashes(path); this.location = StringUtils.trimSlashes(location); this.responseHeaders = immutableMap(responseHeaders); }
/** * Constructor. * * @param vars The Var classes used for resolving string variables. * @param contextObjects Read-only context objects. */ public VarResolverContext(Class<? extends Var>[] vars, Map<String,Object> contextObjects) { this.vars = Arrays.copyOf(vars, vars.length); Map<String,Var> m = new ConcurrentSkipListMap<>(); for (Class<?> c : vars) { if (! isParentClass(Var.class, c)) throw new VarResolverException("Invalid variable class. Must extend from Var"); Var v = newInstance(Var.class, c); m.put(v.getName(), v); } this.varMap = unmodifiableMap(m); this.contextObjects = immutableMap(contextObjects); }
/** * Constructor. * * @param vars The Var classes used for resolving string variables. * @param contextObjects Read-only context objects. */ public VarResolverContext(Class<? extends Var>[] vars, Map<String,Object> contextObjects) { this.vars = Arrays.copyOf(vars, vars.length); Map<String,Var> m = new ConcurrentSkipListMap<>(); for (Class<?> c : vars) { if (! isParentClass(Var.class, c)) throw new VarResolverException("Invalid variable class. Must extend from Var"); Var v = newInstance(Var.class, c); m.put(v.getName(), v); } this.varMap = unmodifiableMap(m); this.contextObjects = immutableMap(contextObjects); }
/** * Constructor. * * @param vars The Var classes used for resolving string variables. * @param contextObjects Read-only context objects. */ public VarResolverContext(Class<? extends Var>[] vars, Map<String,Object> contextObjects) { this.vars = Arrays.copyOf(vars, vars.length); Map<String,Var> m = new ConcurrentSkipListMap<>(); for (Class<?> c : vars) { if (! isParentClass(Var.class, c)) throw new VarResolverException("Invalid variable class. Must extend from Var"); Var v = newInstance(Var.class, c); m.put(v.getName(), v); } this.varMap = unmodifiableMap(m); this.contextObjects = immutableMap(contextObjects); }