当前位置: 首页>>代码示例>>Java>>正文


Java URIUtil类代码示例

本文整理汇总了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;
}
 
开发者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类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。