本文整理汇总了Java中org.netbeans.api.java.classpath.ClassPath.getResourceName方法的典型用法代码示例。如果您正苦于以下问题:Java ClassPath.getResourceName方法的具体用法?Java ClassPath.getResourceName怎么用?Java ClassPath.getResourceName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.java.classpath.ClassPath
的用法示例。
在下文中一共展示了ClassPath.getResourceName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: classToSourceURL
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
private String classToSourceURL (FileObject fo) {
try {
ClassPath cp = ClassPath.getClassPath (fo, ClassPath.EXECUTE);
FileObject root = cp.findOwnerRoot (fo);
String resourceName = cp.getResourceName (fo, '/', false);
if (resourceName == null) {
getProject().log("Can not find classpath resource for "+fo+", skipping...", Project.MSG_ERR);
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;
}
}
示例2: computePersistentFile
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
private File computePersistentFile(FileObject file, String extension) throws IOException {
ClassPath cp = Utilities.getSourceClassPathFor(file);
if (cp == null)
return null;
FileObject root = cp.findOwnerRoot(file);
if (root == null) {
LOG.log(Level.FINE, "file={0} does not have a root on its own source classpath", file); //NOI18N
return null;
}
String resourceName = cp.getResourceName(file, File.separatorChar, true);
File cacheRoot = getCacheRoot(root.toURL());
File cacheFile = computePersistentFile(cacheRoot, resourceName, extension);
return cacheFile;
}
示例3: updateClassName
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
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());
}
}
}
}
示例4: getSourceAndTestClassNames
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
/**
* Finds <code>SourceGroup</code>s where a test for the given class
* can be created (so that it can be found by the projects infrastructure
* when a test for the class is to be opened or run).
*
* @param fo <code>FileObject</code> to find Source and Test filenames for
* @param isTestNG {@code true} if user wants to create TestNG test, {@code false} otherwise
* @param isSelenium {@code true} if user wants to create Selenium test, {@code false} otherwise
* @return an array of Strings - the first one being the source class name
* and the second being the test class name.
* the returned array may be empty but not <code>null</code>
*/
public static String[] getSourceAndTestClassNames(FileObject fo, boolean isTestNG, boolean isSelenium) {
String[] result = {"", ""};
ClassPath cp = ClassPath.getClassPath(fo, ClassPath.SOURCE);
if (cp != null) {
result[0] = cp.getResourceName(fo, '.', false);
String suffix = "";
if(isTestNG) {
suffix = TestCreatorProvider.TESTNG_TEST_CLASS_SUFFIX;
}
if(isSelenium) {
suffix = TestCreatorProvider.INTEGRATION_TEST_CLASS_SUFFIX;
} else {
suffix = suffix.concat(TestCreatorProvider.TEST_CLASS_SUFFIX);
}
result[1] = result[0].concat(suffix);
}
return result;
}
示例5: getResourceName
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
@CheckForNull
private static String getResourceName (@NullAllowed final CompilationUnitTree cu) {
if (cu instanceof JCTree.JCCompilationUnit) {
JavaFileObject jfo = ((JCTree.JCCompilationUnit)cu).sourcefile;
if (jfo != null) {
URI uri = jfo.toUri();
if (uri != null && uri.isAbsolute()) {
try {
FileObject fo = URLMapper.findFileObject(uri.toURL());
if (fo != null) {
ClassPath cp = ClassPath.getClassPath(fo,ClassPath.SOURCE);
if (cp != null) {
return cp.getResourceName(fo,'.',false);
}
}
} catch (MalformedURLException e) {
Exceptions.printStackTrace(e);
}
}
}
}
return null;
}
示例6: getRenamedPackageName
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
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;
}
}
示例7: getTestedLocation
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
/**
*
*/
protected Location getTestedLocation(Location testLocation) {
FileObject fileObj = testLocation.getFileObject();
ClassPath srcCp;
if (fileObj.isFolder()
|| ((srcCp = ClassPath.getClassPath(fileObj, SOURCE)) == null)) {
return null;
}
String baseResName = srcCp.getResourceName(fileObj, '/', false);
if (baseResName == null) {
return null; //if the selectedFO is not within the classpath
}
String srcResName = getSrcResName(baseResName, fileObj.getExt());
if (srcResName == null) {
return null; //if the selectedFO is not a test class (by name)
}
return getOppositeLocation(testLocation,
srcCp,
srcResName,
false);
}
示例8: getTestedLocation
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
@Override
protected Location getTestedLocation(Location testLocation) {
FileObject fileObj = testLocation.getFileObject();
ClassPath srcCp;
if (fileObj.isFolder()
|| ((srcCp = ClassPath.getClassPath(fileObj, ClassPath.SOURCE)) == null)) {
return null;
}
String baseResName = srcCp.getResourceName(fileObj, '/', false);
if (baseResName == null) {
return null; //if the selectedFO is not within the classpath
}
String srcResName = getSrcResName(baseResName, fileObj.getExt());
if (srcResName == null) {
return null; //if the selectedFO is not a test class (by name)
}
return getOppositeLocation(testLocation,
srcCp,
srcResName,
false);
}
示例9: classToSourceURL
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
private String classToSourceURL (FileObject fo, OutputWriter logger) {
ClassPath cp = ClassPath.getClassPath (fo, ClassPath.EXECUTE);
if (cp == null) {
return null;
}
FileObject root = cp.findOwnerRoot (fo);
String resourceName = cp.getResourceName (fo, '/', false);
if (resourceName == null) {
logger.println("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.toURL ()).getRoots ();
ClassPath sourcePath = ClassPathSupport.createClassPath (sRoots);
FileObject rfo = sourcePath.findResource (resourceName + ".java");
if (rfo == null) {
return null;
}
return rfo.toURL ().toExternalForm ();
}
示例10: getText
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
@Override
public String getText(boolean isLogical) {
ClassPath cp = ClassPath.getClassPath(fo, ClassPath.SOURCE);
if (cp==null) {
return fo.getPath();
} else {
if (getJavaSourceGroup(fo)!=null) {
String resourceName = cp.getResourceName(fo);
if (resourceName == null) {
return fo.getPath();
}
String name = resourceName.replace('/','.');
if ("".equals(name)) {
return NbBundle.getMessage(FolderTreeElement.class, "LBL_DefaultPackage_PDU");
}
return name;
} else {
return fo.getPath();
}
}
}
示例11: getDOPackageName
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
private static String getDOPackageName(FileObject f) {
ClassPath cp = ClassPath.getClassPath(f, ClassPath.SOURCE);
if (cp != null) {
return cp.getResourceName(f, '.', false);
} else {
return f.getName();
}
}
示例12: getPackageName
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
public static String getPackageName(FileObject folder) {
ClassPath cp = ClassPath.getClassPath(folder, ClassPath.SOURCE);
if (cp != null) {
return cp.getResourceName(folder, '.', false);
}
return null;
}
示例13: getPackage
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
/**
* 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;
}
}
示例14: getTestName
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
/**
* 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;
}
示例15: determineType
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
@Override
public TypeHelper determineType(RADComponent comp) {
TypeHelper type;
if (comp.getFormModel().getTopRADComponent() == comp) {
FileObject fob = FormEditor.getFormDataObject(comp.getFormModel()).getPrimaryFile();
ClassPath cp = ClassPath.getClassPath(fob, ClassPath.SOURCE);
String className = cp.getResourceName(fob, '.', false);
type = new TypeHelper(className);
} else {
Type t = null;
Map<String,TypeHelper> newMap = null;
Class clazz = comp.getBeanClass();
t = clazz;
if (clazz.getTypeParameters().length == 1) {
try {
TypeHelper elemType = determineTypeParameter(comp);
if (elemType != null) {
newMap = new HashMap<String,TypeHelper>();
newMap.put(clazz.getTypeParameters()[0].getName(), elemType);
}
} catch (Exception ex) {
Logger.getLogger(BindingDesignSupportImpl.class.getName()).log(Level.INFO, ex.getMessage(), ex);
}
}
type = new TypeHelper(t, newMap);
}
return type;
}