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


Java ClassPath.getResourceName方法代码示例

本文整理汇总了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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:JPDAReload.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:TaskCache.java

示例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());
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:CommonTestsCfgOfCreate.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:JavaUtils.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:SourceAnalyzerFactory.java

示例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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:SpringRefactorings.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:DefaultPlugin.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:DefaultITPlugin.java

示例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 ();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:DebuggerChecker.java

示例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();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:FolderTreeElement.java

示例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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:MoveMappingFilesRefactoringUI.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:HibernateRefactoringUtil.java

示例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;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:JUnitTestCreatorProvider.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ProjectUtilities.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:BindingDesignSupportImpl.java


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