本文整理汇总了Java中org.abstractmeta.toolbox.compilation.compiler.util.URIUtil类的典型用法代码示例。如果您正苦于以下问题:Java URIUtil类的具体用法?Java URIUtil怎么用?Java URIUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
URIUtil类属于org.abstractmeta.toolbox.compilation.compiler.util包,在下文中一共展示了URIUtil类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findClassInJarFile
import org.abstractmeta.toolbox.compilation.compiler.util.URIUtil; //导入依赖的package包/类
protected Class<?> findClassInJarFile(String qualifiedClassName) throws ClassNotFoundException {
URI classUri = URIUtil.buildUri(StandardLocation.CLASS_OUTPUT, qualifiedClassName);
String internalClassName = classUri.getPath().substring(1);
JarFile jarFile = null;
try {
for (int i = 0; i < jarFiles.size(); i++) {
jarFile = jarFiles.get(i);
JarEntry jarEntry = jarFile.getJarEntry(internalClassName);
if (jarEntry != null) {
InputStream inputStream = jarFile.getInputStream(jarEntry);
try {
byte[] byteCode = new byte[(int) jarEntry.getSize()];
ByteStreams.read(inputStream, byteCode, 0, byteCode.length);
return defineClass(qualifiedClassName, byteCode, 0, byteCode.length);
} finally {
Closeables.closeQuietly(inputStream);
}
}
}
} catch (IOException e) {
throw new IllegalStateException(String.format("Failed to lookup class %s in jar file %s", qualifiedClassName, jarFile), e);
}
return null;
}
示例2: findClassInJarFile
import org.abstractmeta.toolbox.compilation.compiler.util.URIUtil; //导入依赖的package包/类
protected Class<?> findClassInJarFile(String qualifiedClassName) throws ClassNotFoundException {
URI classUri = URIUtil.buildUri(StandardLocation.CLASS_OUTPUT, qualifiedClassName);
String internalClassName = classUri.getPath().substring(1);
JarFile jarFile = null;
try {
for (int i = 0; i < jarFiles.size(); i++) {
jarFile = jarFiles.get(i);
JarEntry jarEntry = jarFile.getJarEntry(internalClassName);
if (jarEntry != null) {
try (DataInputStream inputStream = new DataInputStream(jarFile.getInputStream(jarEntry))) {
byte[] byteCode = new byte[(int) jarEntry.getSize()];
inputStream.readFully(byteCode);
return defineClass(qualifiedClassName, byteCode, 0, byteCode.length);
}
}
}
} catch (IOException e) {
throw new IllegalStateException(String.format("Failed to lookup class %s in jar file %s", qualifiedClassName, jarFile), e);
}
return null;
}
示例3: getFileForInput
import org.abstractmeta.toolbox.compilation.compiler.util.URIUtil; //导入依赖的package包/类
@Override
public FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException {
URI uri = URIUtil.buildUri(location, packageName, relativeName);
if (javaFileObjectRegistry.isRegistered(uri)) {
return javaFileObjectRegistry.get(uri);
}
return super.getFileForInput(location, packageName, relativeName);
}
示例4: getJavaFileForOutput
import org.abstractmeta.toolbox.compilation.compiler.util.URIUtil; //导入依赖的package包/类
public JavaFileObject getJavaFileForOutput(Location location, String qualifiedName, JavaFileObject.Kind kind, FileObject outputFile) throws IOException {
if (kind == JavaFileObject.Kind.CLASS) {
JavaFileObject result = new JavaCodeFileObject(URIUtil.buildUri(location, qualifiedName));
javaFileObjectRegistry.register(result);
return result;
} else {
throw new IllegalStateException(String.format("Unsupported kind: %s for %s", kind, qualifiedName));
}
}
示例5: addJavaSource
import org.abstractmeta.toolbox.compilation.compiler.util.URIUtil; //导入依赖的package包/类
@Override
public void addJavaSource(String className, String source) {
URI sourceUri = URIUtil.buildUri(StandardLocation.SOURCE_OUTPUT, className);
registry.register(new JavaSourceFileObject(sourceUri, source));
}
示例6: addJavaSource
import org.abstractmeta.toolbox.compilation.compiler.util.URIUtil; //导入依赖的package包/类
@Override
public void addJavaSource(String className, String source) {
URI sourceUri = URIUtil.buildUri(StandardLocation.SOURCE_OUTPUT, className);
registry.register(new JavaSourceFileObject(sourceUri, source));
}