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


Java FileObject.getData方法代码示例

本文整理汇总了Java中org.openide.filesystems.FileObject.getData方法的典型用法代码示例。如果您正苦于以下问题:Java FileObject.getData方法的具体用法?Java FileObject.getData怎么用?Java FileObject.getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openide.filesystems.FileObject的用法示例。


在下文中一共展示了FileObject.getData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: scanForPackages

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
 * Scan recursively through all folders in the given <code>dir</code> and
 * add every directory/package, which contains at least one file with the
 * given extension (probably class or java), into the given
 * <code>validPkgs</code> set. Added entries are in the form of regular java
 * package (x.y.z)
 */
private static void scanForPackages(final Set<FileObject> validPkgs, final FileObject dir, final String ext) {
    if (dir == null) {
        return;
    }
    for (Enumeration en1 = dir.getFolders(false); en1.hasMoreElements(); ) {
        FileObject subDir = (FileObject) en1.nextElement();
        if (VisibilityQuery.getDefault().isVisible(subDir)) {
            scanForPackages(validPkgs, subDir, ext);
        }
    }
    for (Enumeration en2 = dir.getData(false); en2.hasMoreElements(); ) {
        FileObject kid = (FileObject) en2.nextElement();
        if (kid.hasExt(ext) && Utilities.isJavaIdentifier(kid.getName())) {
            // at least one class inside directory -> valid package
            validPkgs.add(dir);
            break;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ApisupportAntUtils.java

示例2: getJavaSources

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static List<JavaSource> getJavaSources(Project project) {
    List<JavaSource> result = new ArrayList<JavaSource>();
    SourceGroup[] groups = SourceGroupSupport.getJavaSourceGroups(project);

    for (SourceGroup group : groups) {
        FileObject root = group.getRootFolder();
        Enumeration<? extends FileObject> files = root.getData(true);

        while (files.hasMoreElements()) {
            FileObject fobj = files.nextElement();

            if (fobj.getExt().equals(JAVA_EXT)) {
                JavaSource source = JavaSource.forFileObject(fobj);
                result.add(source);
            }
        }
    }

    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:JavaSourceHelper.java

示例3: processFolder

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static void processFolder(FileObject file, NameObtainer nameObtainer, SortedSet<String> result, boolean onlyRoots) {
    Enumeration<? extends FileObject> dataFiles = file.getData(false);
    Enumeration<? extends FileObject> folders = file.getFolders(false);

    if (dataFiles.hasMoreElements()) {
        while (dataFiles.hasMoreElements()) {
            FileObject kid = dataFiles.nextElement();
            if ((kid.hasExt("java") || kid.hasExt("class")) && Utilities.isJavaIdentifier(kid.getName())) {
                // at least one java or class inside directory -> valid package
                String packageName = nameObtainer.getPackageName(file);
                if (packageName == null) {
                    continue;
                }
                result.add(packageName);
                if (onlyRoots) {
                    // don't recurse into subfolders
                    return;
                } else {
                    // recurse inot subfolders
                    break;
                }
            }
        }
    }

    while (folders.hasMoreElements()) {
        processFolder(folders.nextElement(), nameObtainer, result, onlyRoots);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:FileUtilities.java


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