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


Java ICodeBase.lookupResource方法代码示例

本文整理汇总了Java中edu.umd.cs.findbugs.classfile.ICodeBase.lookupResource方法的典型用法代码示例。如果您正苦于以下问题:Java ICodeBase.lookupResource方法的具体用法?Java ICodeBase.lookupResource怎么用?Java ICodeBase.lookupResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.umd.cs.findbugs.classfile.ICodeBase的用法示例。


在下文中一共展示了ICodeBase.lookupResource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: search

import edu.umd.cs.findbugs.classfile.ICodeBase; //导入方法依赖的package包/类
/**
 * Search list of codebases for named resource.
 *
 * @param codeBaseList
 *            list of codebases to search
 * @param resourceName
 *            name of resourse
 * @return codebase entry for the named resource, or null if the named
 *         resource cannot be found
 */
private ICodeBaseEntry search(List<? extends ICodeBase> codeBaseList, String resourceName) {
    for (ICodeBase codeBase : codeBaseList) {
        ICodeBaseEntry resource = codeBase.lookupResource(resourceName);
        if (resource != null) {
            return resource;
        }
        // Ignore, continue trying other codebases
    }
    return null;
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:21,代码来源:ClassPathImpl.java

示例2: scanJarManifestForClassPathEntries

import edu.umd.cs.findbugs.classfile.ICodeBase; //导入方法依赖的package包/类
/**
 * Check a codebase for a Jar manifest to examine for Class-Path entries.
 * 
 * @param workList
 *            the worklist
 * @param codeBase
 *            the codebase for examine for a Jar manifest
 * @throws IOException
 */
private void scanJarManifestForClassPathEntries(LinkedList<WorkListItem> workList, ICodeBase codeBase) throws IOException {
    // See if this codebase has a jar manifest
    ICodeBaseEntry manifestEntry = codeBase.lookupResource("META-INF/MANIFEST.MF");
    if (manifestEntry == null) {
        // Do nothing - no Jar manifest found
        return;
    }

    // Try to read the manifest
    InputStream in = null;
    try {
        in = manifestEntry.openResource();
        Manifest manifest = new Manifest(in);

        Attributes mainAttrs = manifest.getMainAttributes();
        String classPath = mainAttrs.getValue("Class-Path");
        if (classPath != null) {
            String[] pathList = classPath.split("\\s+");

            for (String path : pathList) {
                // Create a codebase locator for the classpath entry
                // relative to the codebase in which we discovered the Jar
                // manifest
                ICodeBaseLocator relativeCodeBaseLocator = codeBase.getCodeBaseLocator().createRelativeCodeBaseLocator(path);

                // Codebases found in Class-Path entries are always
                // added to the aux classpath, not the application.
                addToWorkList(workList, new WorkListItem(relativeCodeBaseLocator, false, ICodeBase.IN_JAR_MANIFEST));
            }
        }
    } finally {
        if (in != null) {
            IO.close(in);
        }
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:46,代码来源:ClassPathBuilder.java

示例3: scanJarManifestForClassPathEntries

import edu.umd.cs.findbugs.classfile.ICodeBase; //导入方法依赖的package包/类
/**
 * Check a codebase for a Jar manifest to examine for Class-Path entries.
 *
 * @param workList
 *            the worklist
 * @param codeBase
 *            the codebase for examine for a Jar manifest
 * @throws IOException
 */
private void scanJarManifestForClassPathEntries(LinkedList<WorkListItem> workList, ICodeBase codeBase) throws IOException {
    // See if this codebase has a jar manifest
    ICodeBaseEntry manifestEntry = codeBase.lookupResource("META-INF/MANIFEST.MF");
    if (manifestEntry == null) {
        // Do nothing - no Jar manifest found
        return;
    }

    // Try to read the manifest
    InputStream in = null;
    try {
        in = manifestEntry.openResource();
        Manifest manifest = new Manifest(in);

        Attributes mainAttrs = manifest.getMainAttributes();
        String classPath = mainAttrs.getValue("Class-Path");
        if (classPath != null) {
            String[] pathList = classPath.split("\\s+");

            for (String path : pathList) {
                // Create a codebase locator for the classpath entry
                // relative to the codebase in which we discovered the Jar
                // manifest
                ICodeBaseLocator relativeCodeBaseLocator = codeBase.getCodeBaseLocator().createRelativeCodeBaseLocator(path);

                // Codebases found in Class-Path entries are always
                // added to the aux classpath, not the application.
                addToWorkList(workList,
                        new WorkListItem(relativeCodeBaseLocator, false, ICodeBase.Discovered.IN_JAR_MANIFEST));
            }
        }
    } finally {
        if (in != null) {
            IO.close(in);
        }
    }
}
 
开发者ID:OpenNTF,项目名称:FindBug-for-Domino-Designer,代码行数:47,代码来源:ClassPathBuilder.java


注:本文中的edu.umd.cs.findbugs.classfile.ICodeBase.lookupResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。