本文整理汇总了Java中org.openide.filesystems.FileObject.isData方法的典型用法代码示例。如果您正苦于以下问题:Java FileObject.isData方法的具体用法?Java FileObject.isData怎么用?Java FileObject.isData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.filesystems.FileObject
的用法示例。
在下文中一共展示了FileObject.isData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isProject
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
@CheckForNull
public Result isProject(@NonNull final FileObject projectDirectory) {
final FileObject marker = projectDirectory.getFileObject(PATTERN);
if (marker != null && marker.isData()) {
return new Result(
Lookup.EMPTY,
new Callable<Project>() {
@Override
public Project call() throws Exception {
return new OpenedProject(projectDirectory);
}
},
"Automatic Project", //NOI18N
null);
}
return null;
}
示例2: isValidPackage
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static boolean isValidPackage (FileObject root, final String path) {
//May be null when nothing selected in the GUI.
if (root == null) {
return false;
}
if (path == null) {
return false;
}
final StringTokenizer tk = new StringTokenizer(path,"."); //NOI18N
while (tk.hasMoreTokens()) {
root = root.getFileObject(tk.nextToken());
if (root == null) {
return true;
}
else if (root.isData()) {
return false;
}
}
return true;
}
示例3: forProject
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public ProjectHudsonJobCreator forProject(Project project) {
FileObject projectXml = project.getProjectDirectory().getFileObject("nbproject/project.xml"); // NOI18N
if (projectXml != null && projectXml.isData()) {
try {
Document doc = XMLUtil.parse(new InputSource(projectXml.getURL().toString()), false, true, null, null);
String type = XPathFactory.newInstance().newXPath().evaluate(
"/*/*[local-name(.)='type']", doc.getDocumentElement()); // NOI18N
for (AntBasedJobCreator handler : Lookup.getDefault().lookupAll(AntBasedJobCreator.class)) {
if (handler.type().equals(type)) {
return new JobCreator(project, handler.forProject(project));
}
}
} catch (Exception x) {
Logger.getLogger(JobCreator.class.getName()).log(Level.FINE, "Could not check type of " + projectXml, x);
}
}
return null;
}
示例4: getSupportedMimeTypes
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static List<String> getSupportedMimeTypes () {
List<String> result = new ArrayList<String> ();
FileSystem fs = Repository.getDefault ().getDefaultFileSystem ();
FileObject root = fs.findResource ("Editors");
Enumeration e1 = root.getChildren (false);
while (e1.hasMoreElements ()) {
FileObject f1 = (FileObject) e1.nextElement ();
if (f1.isData ()) continue;
Enumeration e2 = f1.getChildren (false);
while (e2.hasMoreElements ()) {
FileObject f2 = (FileObject) e2.nextElement ();
if (f2.isData ()) continue;
FileObject fo = f2.getFileObject ("language.nbs");
if (fo == null) continue;
result.add (f1.getName () + '/' + f2.getName ());
}
}
return result;
}
示例5: isData
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private boolean isData(final FileObject fo) {
Boolean isd = isDataResult.getAndSet(null);
if (isd != null) {
return isd;
} else {
return fo.isData();
}
}
示例6: verifyContent
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
protected void verifyContent(FileObject sourceRoot, File... files) throws Exception {
List<FileObject> todo = new LinkedList<FileObject>();
todo.add(sourceRoot);
Map<String, String> content = new HashMap<String, String>();
FileUtil.refreshFor(FileUtil.toFile(sourceRoot));
while (!todo.isEmpty()) {
FileObject file = todo.remove(0);
if (file.isData()) {
content.put(FileUtil.getRelativePath(sourceRoot, file), copyFileToString(FileUtil.toFile(file)));
} else {
todo.addAll(Arrays.asList(file.getChildren()));
}
}
for (File f : files) {
String fileContent = content.remove(f.filename);
assertNotNull(f);
assertNotNull(f.content);
assertNotNull("Cannot find " + f.filename + " in map " + content, fileContent);
assertEquals(getName() ,f.content.replaceAll("[ \t\r\n\n]+", " "), fileContent.replaceAll("[ \t\r\n\n]+", " "));
}
assertTrue(content.toString(), content.isEmpty());
}
示例7: Sources
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
* consult the SourceGroup cache, return true if anything changed..
*/
@Messages({
"# {0} - name suffix", "SG_Generated_Sources=Generated Sources ({0})",
"# {0} - name suffix", "SG_Generated_Test_Sources=Generated Test Sources ({0})"
})
private boolean checkGeneratedGroupCache(FileObject root, File rootFile, String nameSuffix, boolean test) {
SourceGroup group = genSrcGroup.get(rootFile);
if ((root == null || root.isData()) && group != null) {
genSrcGroup.remove(rootFile);
return true;
}
if (root == null || root.isData()) {
return false;
}
boolean changed = false;
String name = (test ? NAME_GENERATED_TEST_SOURCE : NAME_GENERATED_SOURCE) + nameSuffix;
String displayName = test ? SG_Generated_Test_Sources(nameSuffix) : SG_Generated_Sources(nameSuffix);
if (group == null) {
group = new GeneratedGroup(project(), root, name, displayName);
genSrcGroup.put(rootFile, group);
changed = true;
} else {
if (!group.getRootFolder().isValid() || !group.getRootFolder().equals(root)) {
group = new GeneratedGroup(project(), root, name, displayName);
genSrcGroup.put(rootFile, group);
changed = true;
}
}
return changed;
}
示例8: loadProject
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public @Override Project loadProject(FileObject fileObject, ProjectState projectState) throws IOException {
if (!isProject(fileObject)) {
return null;
}
FileObject projectFile = fileObject.getFileObject("pom.xml"); //NOI18N
if (projectFile == null || !projectFile.isData()) {
return null;
}
atLeastOneMavenProjectAround.set(true);
return new NbMavenProjectImpl(fileObject, projectFile, projectState);
}
示例9: computeInstances
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void computeInstances() {
ArrayList<MarkProviderCreator> newCreators = new ArrayList<MarkProviderCreator>();
ArrayList<UpToDateStatusProviderFactory> newFactories = new ArrayList<UpToDateStatusProviderFactory>();
for(FileObject f : instanceFiles) {
if (!f.isValid() || !f.isData()) {
continue;
}
try {
DataObject d = DataObject.find(f);
InstanceCookie ic = d.getLookup().lookup(InstanceCookie.class);
if (ic != null) {
if (MarkProviderCreator.class.isAssignableFrom(ic.instanceClass())) {
MarkProviderCreator creator = (MarkProviderCreator) ic.instanceCreate();
newCreators.add(creator);
} else if (UpToDateStatusProviderFactory.class.isAssignableFrom(ic.instanceClass())) {
UpToDateStatusProviderFactory factory = (UpToDateStatusProviderFactory) ic.instanceCreate();
newFactories.add(factory);
}
}
} catch (Exception e) {
LOG.log(Level.WARNING, null, e);
}
}
this.creators = newCreators;
this.factories = newFactories;
}
示例10: resolveIconPath
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
* translates resource path defined in {@link java.beans.BeanInfo}'s subclass
* that complies with {@link Class#getResource(java.lang.String) Class.getResource} format
* to format complying with {@link ClassPath#getResourceName(org.openide.filesystems.FileObject) ClassPath.getResourceName}
* @param resourcePath absolute path or path relative to package of BeanInfo's subclass
* @param beanInfo BeanInfo's subclass
* @return path as URL
* @throws FileStateInvalidException invalid FileObject
* @throws FileNotFoundException resource cannot be found
*/
private static URL resolveIconPath(String resourcePath, FileObject beanInfo)
throws FileStateInvalidException, FileNotFoundException {
ClassPath cp = ClassPath.getClassPath(beanInfo, ClassPath.SOURCE);
String path = resourcePath.charAt(0) != '/'
? '/' + cp.getResourceName(beanInfo.getParent()) + '/' + resourcePath
: resourcePath;
FileObject res = cp.findResource(path);
if (res != null && res.canRead() && res.isData()) {
return res.getURL();
} else {
throw new FileNotFoundException(path);
}
}
示例11: verifyContent
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
protected void verifyContent(FileObject sourceRoot, RefTestBase.File... files) throws Exception {
List<FileObject> todo = new LinkedList<FileObject>();
todo.add(sourceRoot);
Map<String, String> content = new HashMap<String, String>();
FileUtil.refreshFor(FileUtil.toFile(sourceRoot));
while (!todo.isEmpty()) {
FileObject file = todo.remove(0);
if (file.isData()) {
content.put(FileUtil.getRelativePath(sourceRoot, file), TestUtilities.copyFileToString(FileUtil.toFile(file)));
} else {
todo.addAll(Arrays.asList(file.getChildren()));
}
}
for (RefTestBase.File f : files) {
String fileContent = content.remove(f.filename);
assertNotNull(f);
assertNotNull(f.content);
assertNotNull("Cannot find " + f.filename + " in map " + content, fileContent);
assertEquals(getName() ,f.content.replaceAll("[ \t\n]+", " "), fileContent.replaceAll("[ \t\n]+", " "));
}
assertTrue(content.toString(), content.isEmpty());
}
示例12: installModuleName
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
boolean installModuleName(
@NullAllowed FileObject root,
@NullAllowed final FileObject fo) {
if (fo != null && fo.isData() &&
(FileObjects.MODULE_INFO.equals(fo.getName()) || FileObjects.CLASS.equals(fo.getExt()))) {
//No needed to install module name for module-info or class file
return false;
}
if (root == null && fo != null) {
root = computeRootIfAbsent(fo, (f) -> {
final ClassPath src = ClassPath.getClassPath(f, ClassPath.SOURCE);
FileObject owner = src != null ?
src.findOwnerRoot(f) :
null;
if (owner == null && f.isData() && FileUtil.getMIMEType(f, null, JavacParser.MIME_TYPE) != null) {
String pkg = parsePackage(f);
String[] pkgElements = pkg.isEmpty() ?
new String[0] :
pkg.split("\\."); //NOI18N
owner = f.getParent();
for (int i = 0; owner != null && i < pkgElements.length; i++) {
owner = owner.getParent();
}
}
return owner;
});
}
if (root == null || JavaIndex.hasSourceCache(root.toURL(), false)) {
return false;
}
String name = computeModuleIfAbsent(root, (r) -> {
final FileObject moduleInfo = r.getFileObject(FileObjects.MODULE_INFO,FileObjects.JAVA);
if (moduleInfo == null || !moduleInfo.isData() || !moduleInfo.canRead()) {
return null;
}
return SourceUtils.parseModuleName(moduleInfo);
});
moduleName.set(name);
return true;
}
示例13: register
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static void register(FileObject fo) {
Ext<?> ext = ext();
if (ext == null) {
return;
}
if (fo.isData()) {
fo = fo.getParent();
}
ext.register(fo);
}
示例14: bindComponentToFile
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
* Bind given component and given file together.
*
* @param fileObject to bind
* @param offset position at which content of the component will be virtually placed
* @param length how many characters replace from the original file
* @param component component to bind
*/
public static void bindComponentToFile(FileObject fileObject, int offset, int length, JTextComponent component) {
Parameters.notNull("fileObject", fileObject); //NOI18N
Parameters.notNull("component", component); //NOI18N
if (!fileObject.isValid() || !fileObject.isData()) {
return;
}
if (offset < 0 || offset > fileObject.getSize()) {
throw new IllegalArgumentException("Invalid offset=" + offset + "; file.size=" + fileObject.getSize()); //NOI18N
}
if (length < 0 || offset + length > fileObject.getSize()) {
throw new IllegalArgumentException("Invalid lenght=" + length + "; offset=" + offset + ", file.size=" + fileObject.getSize()); //NOI18N
}
bind(component, null, fileObject, offset, -1, -1, length, fileObject.getMIMEType());
}
示例15: registerIfSourceMap
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void registerIfSourceMap(FileObject fo) {
if (!fo.isValid() || !fo.isData() ||
!fo.getExt().equalsIgnoreCase(SRC_MAP_EXT) ||
!fo.canRead()) {
return ;
}
LOG.log(Level.FINE, " found source map (?) {0}", fo);
SourceMap sm;
try {
sm = SourceMap.parse(fo.asText("UTF-8"));
} catch (IOException | IllegalArgumentException ex) {
return ;
}
FileObject compiledFO;
String compiledFile = sm.getFile();
if (compiledFile == null) {
compiledFO = findCompiledFile(fo);
} else {
compiledFO = fo.getParent().getFileObject(compiledFile);
}
LOG.log(Level.FINE, " have source map for generated file {0}", compiledFO);
if (compiledFO != null) {
synchronized (sourceMaps) {
sourceMaps.put(fo, sm);
}
smt.registerTranslation(compiledFO, sm);
}
}