當前位置: 首頁>>代碼示例>>Java>>正文


Java URIUtil.buildUri方法代碼示例

本文整理匯總了Java中org.abstractmeta.toolbox.compilation.compiler.util.URIUtil.buildUri方法的典型用法代碼示例。如果您正苦於以下問題:Java URIUtil.buildUri方法的具體用法?Java URIUtil.buildUri怎麽用?Java URIUtil.buildUri使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.abstractmeta.toolbox.compilation.compiler.util.URIUtil的用法示例。


在下文中一共展示了URIUtil.buildUri方法的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;
}
 
開發者ID:twosigma,項目名稱:beaker-notebook-archive,代碼行數:25,代碼來源:SimpleClassLoader.java

示例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;
}
 
開發者ID:vuminhkh,項目名稱:tosca-runtime,代碼行數:22,代碼來源:SimpleClassLoader.java

示例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);
}
 
開發者ID:twosigma,項目名稱:beaker-notebook-archive,代碼行數:9,代碼來源:SimpleJavaFileManager.java

示例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));
    }
}
 
開發者ID:twosigma,項目名稱:beaker-notebook-archive,代碼行數:10,代碼來源:SimpleJavaFileManager.java

示例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));
}
 
開發者ID:twosigma,項目名稱:beaker-notebook-archive,代碼行數:6,代碼來源:JavaSourceCompilerImpl.java

示例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));
}
 
開發者ID:twosigma,項目名稱:beakerx,代碼行數:6,代碼來源:JavaSourceCompilerImpl.java


注:本文中的org.abstractmeta.toolbox.compilation.compiler.util.URIUtil.buildUri方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。