// if not directly on EXECUTE, might be on SOURCE
ClassPath scp = ClassPath.getClassPath( srcFile, ClassPath.SOURCE); // try to find the resource on source class path if ((scp != null) && (scp.getResourceName( resFile, '.',false) != null)) return scp;
// now try resource owner
ClassPath rcp = ClassPath.getClassPath( resFile, ClassPath.SOURCE); // try to find the resource on source class path if ((rcp!=null) && (rcp.getResourceName( resFile, '.',false) != null)) return rcp;
returnnull;
}
/** *Triestofindthebundleeitherinsourcesorinexecution *classpath.
*/ publicstatic FileObject getResource(FileObject srcFile, String bundleName) { // try to find it in sources of the same project
ClassPath scp = ClassPath.getClassPath( srcFile, ClassPath.SOURCE); if (scp != null) {
FileObject ret = scp.findResource(bundleName); if (ret != null) return ret;
}
// try to find in sources of execution classpath
ClassPath ecp = ClassPath.getClassPath( srcFile, ClassPath.EXECUTE); if (ecp != null) { for (ClassPath.Entry e : ecp.entries()) {
SourceForBinaryQuery.Result r = SourceForBinaryQuery.findSourceRoots(e.getURL()); for (FileObject srcRoot : r.getRoots()) { // try to find the bundle under this source root
ClassPath cp = ClassPath.getClassPath(srcRoot, ClassPath.SOURCE); if (cp != null) {
FileObject ret = cp.findResource(bundleName); if (ret != null) return ret;
}
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.