本文整理了Java中org.netbeans.api.java.classpath.ClassPath.getResourceName()
方法的一些代码示例,展示了ClassPath.getResourceName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ClassPath.getResourceName()
方法的具体详情如下:
包路径:org.netbeans.api.java.classpath.ClassPath
类名称:ClassPath
方法名:getResourceName
暂无
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-spring-beans
public static String getPackageName(FileObject folder) {
ClassPath cp = ClassPath.getClassPath(folder, ClassPath.SOURCE);
if (cp != null) {
return cp.getResourceName(folder, '.', false);
}
return null;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-insync
public static String getPackageName(FileObject folder) {
return ClassPath.getClassPath(
folder, ClassPath.SOURCE)
.getResourceName(folder, '.', false);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projects
private static String fileToClassName (FileObject fo) {
// remove ".class" from and use dots for for separator
ClassPath cp = ClassPath.getClassPath (fo, ClassPath.EXECUTE);
if (cp == null) {
logger.log(Level.WARNING, "Did not find EXECUTE class path for {0}", fo);
return null;
}
// FileObject root = cp.findOwnerRoot (fo);
return cp.getResourceName (fo, '.', false);
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-swingapp
/**
* @return corresponding class name for given source file
*/
static String getClassNameForFile(FileObject fo) {
ClassPath cp = ClassPath.getClassPath(fo, ClassPath.SOURCE);
return cp != null ? cp.getResourceName(fo, '.', false) : null;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-junit-ui
private static String getClassName(FileObject fileObj) {
//PENDING: is it ensured that the classpath is non-null?
return ClassPath.getClassPath(fileObj, ClassPath.SOURCE)
.getResourceName(fileObj, '.', false);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-jsf
public static String getPackageName(FileObject folder) {
assert folder.isFolder() : "argument must be folder"; //NOI18N
return ClassPath.getClassPath(
folder, ClassPath.SOURCE)
.getResourceName(folder, '.', false);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-refactoring
private static String getPackageName(FileObject folder) {
assert folder.isFolder() : "argument must be folder";
return ClassPath.getClassPath(
folder, ClassPath.SOURCE)
.getResourceName(folder, '.', false);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-apisupport-project
private @CheckForNull FileObject findBundle(FileObject javaFile) {
ClassPath cp = ClassPath.getClassPath(javaFile, ClassPath.SOURCE);
if (cp == null) {
return null;
}
String name = cp.getResourceName(javaFile);
if (name != null) {
int index = name.lastIndexOf('/');
name = name.substring(0, index) + "/Bundle.properties"; //NOI18N
return cp.findResource(name);
}
return null;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-spring-beans
public static String getRenamedPackageName(FileObject folder, String newName) {
FileObject parent = folder.getParent();
if (parent == null) {
return null;
}
ClassPath cp = ClassPath.getClassPath(parent, ClassPath.SOURCE);
if (cp == null) {
return null;
}
String parentName = cp.getResourceName(parent, '.', false);
if (parentName == null) {
return null;
}
if (parentName.length() > 0) {
return parentName + '.' + newName;
} else {
return newName;
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-selenium2-php
@Override
public String[] getSourceAndTestClassNames(FileObject fo, boolean isTestNG, boolean isSelenium) {
String[] result = {"", ""};
Project p = FileOwnerQuery.getOwner(fo);
if (p != null) {
Collection<? extends ClassPathProvider> providers = p.getLookup().lookupAll(ClassPathProvider.class);
for (ClassPathProvider provider : providers) {
ClassPath cp = provider.findClassPath(fo, PhpSourcePath.SOURCE_CP);
if (cp != null) {
result[0] = cp.getResourceName(fo, '.', false);
result[1] = result[0].concat(TestCreatorProvider.TEST_CLASS_SUFFIX);
}
}
}
return result;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javascript-refactoring
public String getText(boolean isLogical) {
ClassPath cp = ClassPath.getClassPath(fo, ClassPath.SOURCE);
if (cp==null) {
return fo.getPath();
} else {
if (getRubySourceGroup(fo)!=null) {
String name = cp.getResourceName(fo).replace('/','.');
if ("".equals(name))
return NbBundle.getMessage(UiUtils.class, "LBL_DefaultPackage_PDU");
return name;
} else {
return fo.getPath();
}
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-java-testrunner-ui
private static String getPreffiledName(CompilationInfo info, String selectedFramework) {
FileObject fileObj = info.getFileObject();
ClassPath cp = ClassPath.getClassPath(fileObj, ClassPath.SOURCE);
String className = cp.getResourceName(fileObj, '.', false);
return className + getTestingFrameworkSuffix(selectedFramework) + TEST_CLASS_SUFFIX;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-junit-ui
private static String getTestName(ClassPath cp, FileObject selectedFO) {
String resource = cp.getResourceName(selectedFO, '/', false);
String testName = null;
if (selectedFO.isFolder()) {
//find Suite for package
testName = JUnitTestUtil.convertPackage2SuiteName(resource);
} else {
// find Test for class
testName = JUnitTestUtil.convertClass2TestName(resource);
}
return testName;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-swingapp
ResourcePackageUpdate(RenameRefactoring refactoring, RefactoringElementImplementation refElement, FileObject resFolder) {
this.refactoring = refactoring;
this.refElement = refElement;
this.resFolder = DataFolder.findFolder(resFolder);
oldPkgName = ClassPath.getClassPath(resFolder, ClassPath.SOURCE)
.getResourceName(resFolder.getParent(), '.', false);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-swingapp
static PropertiesDataObject getPropertiesDataObject(FileObject srcFile) {
ClassPath cp = ClassPath.getClassPath(srcFile, ClassPath.SOURCE);
if (cp == null) {
return null;
}
String srcClassName = cp.getResourceName(srcFile, '.', false);
String bundleName = getBundleName(srcClassName);
return getPropertiesDataObject(srcFile, bundleName, false);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-form-refactoring
private void componentClassRename(FileObject originalFile) {
String oldName = refInfo.getOldName(originalFile);
String newName = refInfo.getNewName();
String pkg = ClassPath.getClassPath(originalFile, ClassPath.SOURCE)
.getResourceName(originalFile.getParent(), '.', false);
String oldClassName = (pkg != null && pkg.length() > 0)
? pkg + "." + oldName : oldName; // NOI18N
String newClassName = (pkg != null && pkg.length() > 0)
? pkg + "." + newName : newName; // NOI18N
componentChange(oldClassName, newClassName);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-profiler-projectsupport
/**
* Copied from JUnit module implementation in 4.1 and modified
*/
private static String getTestName(ClassPath cp, FileObject selectedFO) {
String resource = cp.getResourceName(selectedFO, '/', false); //NOI18N
String testName = null;
if (selectedFO.isFolder()) {
//find Suite for package
testName = convertPackage2SuiteName(resource);
} else {
// find Test for class
testName = convertClass2TestName(resource);
}
return testName;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-junit-ui
/**
* Get the package name of <code>file</code>.
*
* @param project owner of the file (for performance reasons)
* @param file the FileObject whose packagename to get
* @return package name of the file or null if it cannot be retrieved
*/
private static String getPackage(Project project, FileObject file) {
SourceGroup srcGrp = JUnitTestUtil.findSourceGroupOwner(project, file);
if (srcGrp!= null) {
ClassPath cp = ClassPathSupport.createClassPath(
new FileObject [] {srcGrp.getRootFolder()});
return cp.getResourceName(file, '.', false);
} else {
return null;
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-gsf-testrunner-ui
private void updateClassName() {
if (tfClassName != null) {
boolean shouldShowClassNameInfo = shouldShowClassNameInfo();
tfClassName.setVisible(shouldShowClassNameInfo);
lblClassName.setVisible(shouldShowClassNameInfo);
if (shouldShowClassNameInfo) {
FileObject fileObj = activatedFOs[0];
ClassPath cp = ClassPath.getClassPath(fileObj, ClassPath.SOURCE);
if (cp != null) {
String className = cp.getResourceName(fileObj, '.', false);
String suffix = (selectedTestingFramework != null && selectedTestingFramework.equals(TestCreatorProvider.FRAMEWORK_SELENIUM))
|| (chkIntegrationTests != null && chkIntegrationTests.isEnabled() && chkIntegrationTests.isSelected()) ? TestCreatorProvider.INTEGRATION_TEST_CLASS_SUFFIX : TestCreatorProvider.TEST_CLASS_SUFFIX;
String prefilledName = className + getTestingFrameworkSuffix() + suffix;
tfClassName.setText(prefilledName);
tfClassName.setDefaultText(prefilledName);
tfClassName.setCaretPosition(prefilledName.length());
}
}
}
}
代码示例来源:origin: org.codehaus.mevenide/nb-project
private String classToSourceURL (FileObject fo, Log logger) {
try {
ClassPath cp = ClassPath.getClassPath (fo, ClassPath.EXECUTE);
FileObject root = cp.findOwnerRoot (fo);
String resourceName = cp.getResourceName (fo, '/', false);
if (resourceName == null) {
logger.info("Can not find classpath resource for "+fo+", skipping...");
return null;
}
int i = resourceName.indexOf ('$');
if (i > 0)
resourceName = resourceName.substring (0, i);
FileObject[] sRoots = SourceForBinaryQuery.findSourceRoots
(root.getURL ()).getRoots ();
ClassPath sourcePath = ClassPathSupport.createClassPath (sRoots);
FileObject rfo = sourcePath.findResource (resourceName + ".java");
if (rfo == null) return null;
return rfo.getURL ().toExternalForm ();
} catch (FileStateInvalidException ex) {
ex.printStackTrace ();
return null;
}
}
内容来源于网络,如有侵权,请联系作者删除!