本文整理汇总了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;
}
示例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);
}
}
}
示例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);
}
}
}