本文整理匯總了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;
}
}
}
示例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;
}
示例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);
}
}