/** * @see de.matrixweb.smaller.resource.Resource#getContents() */ @Override public String getContents() throws IOException { return this.merger.merge(this.resources); }
/** * @param resources * The {@link Resource}s to merge * @return Returns the merged resources * @throws IOException */ public String merge(final List<Resource> resources) throws IOException { return this.merge(resources, "\n"); }
/** * @param resolver * The {@link ResourceResolver} to lookup sources * @param in * The list of input files * @return Returns the merged result * @throws IOException * @deprecated */ @Deprecated public String merge(final ResourceResolver resolver, final List<String> in) throws IOException { return merge(getResources(resolver, in)); }
private Resource executeComplexMerge(final VFS vfs, final Resource resource, final Map<String, Object> options) throws IOException { final Object typeOption = options.get("type"); if (!(resource instanceof ResourceGroup) || typeOption != null && resource.getType() != Type.valueOf(typeOption.toString())) { return resource; } final ResourceGroup group = (ResourceGroup) resource; final Resource input = group.getResources().get(0); final VFile snapshot = vfs.stack(); try { final VFile target = vfs.find(input.getPath()); final Writer writer = VFSUtils.createWriter(target); try { writer.write(group.getMerger().merge(group.getResources())); } finally { IOUtils.closeQuietly(writer); } return input.getResolver().resolve(target.getPath()); } catch (final IOException e) { vfs.rollback(snapshot); throw e; } }
VFSUtils.write(file, merge(resources)); return file.getPath();