本文整理匯總了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));
}