本文整理了Java中org.hibnet.webpipes.WebpipeUtils
类的一些代码示例,展示了WebpipeUtils
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebpipeUtils
类的具体详情如下:
包路径:org.hibnet.webpipes.WebpipeUtils
类名称:WebpipeUtils
暂无
代码示例来源:origin: org.hibnet/webpipes-uglify
private UglifyJsWebpipe(String path, Webpipe webpipe, boolean uglify, List<String> revervedNames) {
super(WebpipeUtils.idOf(UglifyJsProcessor.class, webpipe, uglify, revervedNames), path, "uglify", webpipe);
this.uglify = uglify;
this.revervedNames = revervedNames;
}
代码示例来源:origin: org.hibnet/webpipes-core
public static String idOf(Class<?> c, Object... args) {
MessageDigest digest = buildSHA1Digest();
digest(digest, c);
for (Object arg : args) {
digest(digest, arg);
}
return Base64.getEncoder().encodeToString(digest.digest());
}
代码示例来源:origin: org.hibnet/webpipes-core
public FilePatternResource(String path, String pattern) {
super(WebpipeUtils.idOf(FilePatternResource.class, pattern), WebpipeUtils.pathOf(path, "/webpipes/files", pattern));
this.pattern = pattern;
}
代码示例来源:origin: org.hibnet/webpipes-core
public StringResource(String path, String content) {
super(WebpipeUtils.idOf(StringResource.class, content),
WebpipeUtils.pathOf(path, "/webpipes/string", WebpipeUtils.sha1Base64Encoded(content)));
this.output = new WebpipeOutput(content);
}
代码示例来源:origin: org.hibnet/webpipes-core
protected WebpipeOutput callRunner(Object... args) throws Exception {
Object res = invokeFunction("webpipes_runner", args);
Bindings bindings = jsEngine.createBindings();
bindings.put("res", res);
String content = (String) getContentScript.eval(bindings);
String sourceMap = (String) getSourceMapScript.eval(bindings);
return new WebpipeOutput(content, WebpipeUtils.parseSourceMap(sourceMap));
}
代码示例来源:origin: org.hibnet/webpipes-core
public static byte[] sha1(String content) {
return buildSHA1Digest().digest(content.getBytes(UTF8));
}
代码示例来源:origin: org.hibnet/webpipes-core
private int getWildCardCount(String pattern) {
if (pattern.endsWith(".*")) {
pattern = pattern.substring(0, pattern.length() - 2);
}
return WebpipeUtils.countOccurrencesOf(pattern, "*");
}
代码示例来源:origin: org.hibnet/webpipes-core
private static void digest(MessageDigest digest, Object arg) {
if (arg instanceof String) {
digest.update(((String) arg).getBytes(UTF8));
} else if (arg instanceof Boolean) {
digest.update((byte) (((Boolean) arg) ? 1 : 0));
} else if (arg instanceof Number) {
digest.update(((Number) arg).toString().getBytes(UTF8));
} else if (arg instanceof Enum<?>) {
digest.update(((Enum<?>) arg).name().getBytes(UTF8));
} else if (arg instanceof Class<?>) {
digest.update(((Class<?>) arg).getCanonicalName().getBytes(UTF8));
} else if (arg instanceof Webpipe) {
digest.update(((Webpipe) arg).getId().getBytes(UTF8));
} else if (arg instanceof File) {
digest.update(((File) arg).getAbsolutePath().getBytes(UTF8));
} else if (arg instanceof Collection<?>) {
Iterator<?> it = ((Collection<?>) arg).iterator();
while (it.hasNext()) {
digest(digest, it.next());
}
} else {
throw new IllegalArgumentException("Unsupported type: " + arg.getClass().getName());
}
}
}
代码示例来源:origin: org.hibnet/webpipes-core
public ClasspathPatternResource(String path, String pattern) {
super(WebpipeUtils.idOf(ClasspathPatternResource.class, pattern), WebpipeUtils.pathOf(path, "/webpipes/cps", pattern));
this.pattern = pattern;
}
代码示例来源:origin: org.hibnet/webpipes-core
private WebpipeOutput readOutput() throws Exception {
if (cacheDir == null) {
// no durable cache configured
return NOT_INITIALIZED_OUTPUT;
}
File sha1File = new File(cacheDir, getId() + ".sha1");
if (!sha1File.exists()) {
return NOT_INITIALIZED_OUTPUT;
}
byte[] expectedSha1 = computeSHA1();
if (sha1File.length() != expectedSha1.length) {
// wrong size : don't even bother to read it
return NOT_INITIALIZED_OUTPUT;
}
byte[] actualSha1 = readFile(sha1File);
if (!Arrays.equals(expectedSha1, actualSha1)) {
return NOT_INITIALIZED_OUTPUT;
}
// same sha1, get the content out
byte[] data = readFile(new File(cacheDir, getId() + ".txt"));
String content = new String(data, WebpipeUtils.UTF8);
SourceMap sourceMap = null;
File sourceMapFile = new File(cacheDir, getId() + ".map");
if (sourceMapFile.exists()) {
sourceMap = WebpipeUtils.parseSourceMap(readFile(sourceMapFile));
}
return new WebpipeOutput(content, sourceMap);
}
代码示例来源:origin: org.hibnet/webpipes-core
private byte[] computeSHA1() throws Exception {
MessageDigest digest = WebpipeUtils.buildSHA1Digest();
updateDigest(digest);
byte[] sha1 = digest.digest();
return sha1;
}
代码示例来源:origin: org.hibnet/webpipes-core
int wildCardCount2 = getWildCardCount(pattern2);
int bracketCount1 = WebpipeUtils.countOccurrencesOf(pattern1, "{");
int bracketCount2 = WebpipeUtils.countOccurrencesOf(pattern2, "{");
代码示例来源:origin: org.hibnet/webpipes-core
public AbsoluteUrlCssWebpipe(String path, Webpipe webpipe, String absolutePath) {
super(WebpipeUtils.idOf(AbsoluteUrlCssWebpipe.class, webpipe, absolutePath), path, "absoluteUrlCss", webpipe);
this.absolutePath = absolutePath;
}
代码示例来源:origin: org.hibnet/webpipes-core
public ClasspathResource(String path, String location) {
super(WebpipeUtils.idOf(ClasspathResource.class, location), WebpipeUtils.pathOf(path, "/webpipes/cp", location));
this.location = location.startsWith("/") ? location : ("/" + location);
}
代码示例来源:origin: org.hibnet/webpipes-less4j
@Override
protected WebpipeOutput fetchOutput() throws Exception {
synchronized (importedResources) {
importedResources.clear();
Webpipe webpipe = getChildWebpipe();
String content = webpipe.getOutput().getContent();
StringSource lessSource;
if (webpipe instanceof Resource) {
lessSource = new RelativeAwareLessSource((Resource) webpipe, content);
} else {
lessSource = new StringSource(content, webpipe.getPath());
}
CompilationResult result = compiler.compile(lessSource);
logWarnings(result);
return new WebpipeOutput(result.getCss(), WebpipeUtils.parseSourceMap(result.getSourceMap()));
}
}
代码示例来源:origin: org.hibnet/webpipes-core
private static String buildId(List<Webpipe> webpipes) {
if (webpipes.isEmpty()) {
return "empty";
}
MessageDigest digest = WebpipeUtils.buildSHA1Digest();
for (Webpipe webpipe : webpipes) {
digest.update(webpipe.getPath().getBytes(WebpipeUtils.UTF8));
}
return Base64.getEncoder().encodeToString(digest.digest());
}
代码示例来源:origin: org.hibnet/webpipes-yui
private YuiJsCompressorWebpipe(String path, Webpipe webpipe, int linebreak, boolean munge, boolean verbose, boolean preserveAllSemiColons,
boolean disableOptimizations) {
super(WebpipeUtils.idOf(YuiJsCompressorProcessor.class, webpipe, linebreak, munge, verbose, preserveAllSemiColons, disableOptimizations),
path, "yuijs", webpipe);
this.linebreak = linebreak;
this.munge = munge;
this.verbose = verbose;
this.preserveAllSemiColons = preserveAllSemiColons;
this.disableOptimizations = disableOptimizations;
}
代码示例来源:origin: org.hibnet/webpipes-core
public FileResource(String path, File file) {
super(WebpipeUtils.idOf(FileResource.class, file), WebpipeUtils.pathOf(path, "/webpipes/file", file.getAbsolutePath()));
this.file = file;
}
代码示例来源:origin: org.hibnet/webpipes-yui
private YuiCssCompressorWebpipe(String path, Webpipe webpipe, int linebreak) {
super(WebpipeUtils.idOf(YuiCssCompressorProcessor.class, webpipe, linebreak), path, "yuicss", webpipe);
this.linebreak = linebreak;
}
代码示例来源:origin: org.hibnet/webpipes-core
public UrlResource(String path, URL url) {
super(WebpipeUtils.idOf(UrlResource.class, url), WebpipeUtils.pathOf(path, "/webpipes/url", url.toExternalForm()));
this.url = url;
}
内容来源于网络,如有侵权,请联系作者删除!