/** * 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 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; }