CssFileBuilder.java
1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* javax.jcr.Session
* org.apache.commons.io.IOUtils
* org.apache.jackrabbit.util.Text
*/
package com.adobe.granite.ui.clientlibs.impl;
import com.adobe.granite.ui.clientlibs.LibraryType;
import com.adobe.granite.ui.clientlibs.impl.AbstractBuilder;
import com.adobe.granite.ui.clientlibs.script.ScriptResource;
import com.adobe.granite.ui.clientlibs.script.Utils;
import java.io.IOException;
import java.io.Reader;
import java.util.Collection;
import javax.jcr.Session;
import org.apache.commons.io.IOUtils;
import org.apache.jackrabbit.util.Text;
public class CssFileBuilder
extends AbstractBuilder {
private final String[] libPath;
private final Session session;
private final long maxDataUriSize;
public CssFileBuilder(String libraryPath, Session session, long maxDataUriSize) {
super(libraryPath);
this.libPath = Text.explode((String)libraryPath, (int)47);
this.session = session;
this.maxDataUriSize = maxDataUriSize;
}
@Override
public LibraryType getType() {
return LibraryType.CSS;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
@Override
protected String concatenate(Collection<ScriptResource> resources) throws IOException {
StringBuilder out = new StringBuilder();
for (ScriptResource resource : resources) {
String src;
Reader r = resource.getReader();
try {
src = IOUtils.toString((Reader)r);
}
finally {
IOUtils.closeQuietly((Reader)r);
}
String[] filePath = Text.explode((String)resource.getName(), (int)47);
out.append(Utils.rewriteUrlsInCss(this.libPath, filePath, src, this.session, this.maxDataUriSize));
out.append("\n");
}
return out.toString();
}
}