private static Resources createResourceGroupImpl0( final ResourceResolver resolver, final SourceMerger merger, final List<String> files) throws IOException { return new Resources(merger.getResources(resolver, files)); }
/** * @see de.matrixweb.smaller.resource.Resource#getContents() */ @Override public String getContents() throws IOException { return this.merger.merge(this.resources); }
@Override public void exec(final Reader reader, final Writer writer) throws IOException { callback.call(reader, writer); } });
private Resource executeSimpleMerge(final VFS vfs, final Resource resource, final Map<String, Object> options) throws IOException { return resource.getResolver() .resolve( new SourceMerger("once".equals(options.get("source")) ? true : false).getMergedJsonFile(vfs, resource.getResolver(), resource.getPath())); }
/** * @see de.matrixweb.smaller.resource.Resource#getPath() */ @Override public String getPath() { return this.resources.get(0).getPath(); }
private void execute0_0(final VFS vfs, final Resources resources, final List<ProcessorOptions> entries) throws IOException { for (final ProcessorOptions entry : entries) { for (final Type type : Type.values()) { final List<Resource> res = resources.getByType(type); if (res.size() > 0 && entry.processor.supportsType(type)) { LOGGER.info("Executing processor {} for type {}", entry.name, type); final List<Resource> results = new ArrayList<Resource>(); for (final Resource r : res) { results.add(r.apply(vfs, entry.processor, entry.options)); } resources.replace(res, results); } } } }
/** * @see de.matrixweb.smaller.resource.Resource#getResolver() */ @Override public ResourceResolver getResolver() { return this.resources.get(0).getResolver(); }
@Deprecated private static Resources createResourceGroupImpl1( final ResourceResolver resolver, final SourceMerger merger, final List<String> files) throws IOException { final Resources resources = createResourceGroupImpl0(resolver, merger, files); List<Resource> res = resources.getByType(Type.JS); if (res.size() > 1) { resources.replace(res, new MultiResource(merger, resolver, res)); } res = resources.getByType(Type.CSS); if (res.size() > 1) { resources.replace(res, new MultiResource(merger, resolver, res)); } return resources; }
/** * @param vfs * @param input * @param sourceType * @param callback * @return Returns the processed {@link Resource} * @throws IOException */ public static Resource process(final VFS vfs, final Resource input, final String sourceType, final ProcessorCallback callback) throws IOException { return process(vfs, input, sourceType, sourceType, callback); }
/** * @see de.matrixweb.smaller.resource.Resource#apply(de.matrixweb.vfs.VFS, * de.matrixweb.smaller.resource.Processor, java.util.Map) */ @Override public Resource apply(final VFS vfs, final Processor processor, final Map<String, Object> options) throws IOException { return processor.execute(vfs, this, options); }
/** * Replaces all <code>r1</code> {@link Resource}s with <code>r2</code> * {@link Resource}s. * * @param r1 * @param r2 */ public final void replace(final List<Resource> r1, final Resource... r2) { replace(r1, Arrays.asList(r2)); }
/** * @param type * @return Returns the {@link Resource} matching the given type or null if * none available */ public Resource get(final Type type) { if (this.resources == null) { return null; } final List<Resource> res = this.resources.getByType(type); return res.size() > 0 ? res.get(0) : null; }
private ProcessorOptions createTypeMerger(final Type type) { final Map<String, Object> options = new HashMap<String, Object>(); options.put("type", type.name()); return new ProcessorOptions("merge", this.processorFactory.getProcessor("merge"), options); }
@Override public File writeAll() throws IOException { return VFSResource.this.resolver.writeAll(); } };
/** * @param vfs * @param resource * @param sourceType * @param callback * @return Returns the processed {@link Resource} * @throws IOException */ public static Resource processAllFilesOfType(final VFS vfs, final Resource resource, final String sourceType, final ProcessorCallback callback) throws IOException { return processAllFilesOfType(vfs, resource, sourceType, sourceType, callback); }
/** * @see de.matrixweb.smaller.resource.ProcessorFactory#dispose() */ @Override public void dispose() { for (final Processor processor : this.processors.values()) { processor.dispose(); } }
/** * @see de.matrixweb.smaller.resource.Resource#getPath() */ @Override public String getPath() { return this.resources.isEmpty() ? "" : this.resources.get(0).getPath(); }
/** * @see de.matrixweb.smaller.resource.Processor#execute(de.matrixweb.vfs.VFS, * de.matrixweb.smaller.resource.Resource, java.util.Map) */ @Override public Resource execute(final VFS vfs, final Resource resource, final Map<String, Object> options) throws IOException { return ProcessorUtil.process(vfs, resource, "css", new ProcessorCallback() { @Override public void call(final Reader reader, final Writer writer) throws IOException { YcssminProcessor.this.executor.run(reader, writer); } }); }
/** * @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"); }
@Override public void exec(final Reader reader, final Writer writer) throws IOException { callback.call(reader, writer); } });