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


Java FileObject.getFileSystem方法代码示例

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


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

示例1: getURL

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
public URL getURL(FileObject fo, int type) {
    if (type == NETWORK)
        return null;

    try {
        if (fo.getFileSystem() instanceof NBJRTFileSystem) {
            String path = fo.getPath();
            if (fo.isFolder() && !path.isEmpty()) {
                path += "/";    //NOI18N
            }
            //URI.resolve does not work as the nbjrt URI is opaque
            return new URL(String.format(
                "%s%s", //NOI18N
                ((NBJRTFileSystem) fo.getFileSystem()).getRootURL(),
                path));
        }
    } catch (IOException | URISyntaxException ex) {
        LOG.log(Level.FINE, null, ex);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:NBJRTURLMapper.java

示例2: getLibraryVersion

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static String getLibraryVersion(Library library, String className) {
    List<URL> urls = library.getContent("classpath"); // NOI18N
    ClassPath cp = createClassPath(urls);
    try {
        FileObject resource = cp.findResource(className.replace('.', '/') + ".class");  //NOI18N
        if (resource==null) {
            return null;
        }
        FileObject ownerRoot = cp.findOwnerRoot(resource);

        if (ownerRoot !=null) { //NOI18N
            if (ownerRoot.getFileSystem() instanceof JarFileSystem) {
                JarFileSystem jarFileSystem = (JarFileSystem) ownerRoot.getFileSystem();
                return getImplementationVersion(jarFileSystem);
            }
        }
    } catch (FileStateInvalidException e) {
        Exceptions.printStackTrace(e);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:SpringUtilities.java

示例3: findVersion

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private String findVersion(FileObject classpathRoot) {
    ClassPath cp = ClassPath.getClassPath(classpathRoot, ClassPath.COMPILE);
    if (cp == null) {
        return null;
    }
    String classRelativePath = SpringUtilities.SPRING_CLASS_NAME.replace('.', '/') + ".class"; //NOI18N
    try {
        FileObject resource = cp.findResource(classRelativePath);  //NOI18N
        if (resource==null) {
            return null;
        }
        FileObject ownerRoot = cp.findOwnerRoot(resource);

        if (ownerRoot !=null) { //NOI18N
            if (ownerRoot.getFileSystem() instanceof JarFileSystem) {
                JarFileSystem jarFileSystem = (JarFileSystem) ownerRoot.getFileSystem();
                return SpringUtilities.getImplementationVersion(jarFileSystem);
            }
        }
    } catch (FileStateInvalidException e) {
        Exceptions.printStackTrace(e);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:SpringBinaryIndexer.java

示例4: getURL

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public @Override URL getURL(FileObject fo, int type) {
    if (type != URLMapper.INTERNAL) {
        return null;
    }
    try {
        FileSystem fs = fo.getFileSystem();
        if (fs instanceof SourceFS) {
            String path = fo.getPath();
            if (fo.isFolder() && !fo.isRoot()) {
                path += '/';
            }
            return url((SourceFS) fs, path);
        }
    } catch (FileStateInvalidException x) {
        // ignore
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:SourceURLMapper.java

示例5: testValidRoots

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testValidRoots () throws Exception {
    assertNotNull(testedFS.getRoot());    
    assertTrue(testedFS.getRoot().isValid());            
    
    FileSystemView fsv = FileSystemView.getFileSystemView();                
    File[] roots = File.listRoots();
    boolean validRoot = false;
    for (int i = 0; i < roots.length; i++) {
        FileObject root1 = FileUtil.toFileObject(roots[i]);
        if (!roots[i].exists()) {
           assertNull(root1);
           continue; 
        }
        
        assertNotNull(roots[i].getAbsolutePath (),root1);
        assertTrue(root1.isValid());
        if (testedFS == root1.getFileSystem()) {
            validRoot = true;
        }
    }
    assertTrue(validRoot);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:BaseFileObjectTestHid.java

示例6: annotateName

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
public String annotateName (String name, java.util.Set files) {
    StringBuilder sb = new StringBuilder (name);
    Iterator it = files.iterator ();
    while (it.hasNext()) {                    
        FileObject fo = (FileObject)it.next();
        try {
            if (fo.getFileSystem() instanceof IgnoreDirFileSystem) {
                sb.append(",").append (fo.getNameExt());//NOI18N
            }
        } catch (Exception ex) {
            fail ();
        }
    }
                    
    return sb.toString () ;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:BaseFileObjectTestHid.java

示例7: findFileObject

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static FileObject findFileObject(DataObject srcDataObject, String path) {
    FileObject pfo = srcDataObject.getPrimaryFile();
    ClassPath cp = ClassPath.getClassPath(pfo, ClassPath.EXECUTE);

    // #167334
    if(cp == null) {
        LOG.info("Unable to find FileObject due to ClassPath is null");
        return null;
    }

    for(FileObject fo : getRoots(cp)) {
        try {
            FileSystem fs = fo.getFileSystem();
            if (fs != null) {
                FileObject retval = fs.findResource(path);
                if (retval != null) {
                    return retval;
                }
            }
        } catch (FileStateInvalidException ex) {
            LOG.log(Level.INFO, null, ex);
        }
    }
    
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:I18nOptions.java

示例8: getEncoding

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public Charset getEncoding(FileObject f) {
    try {
        if (f.getFileSystem() == fs) {
            return result;
        }
        return null;
    } catch (FileStateInvalidException ex) {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:SCFTHandlerTest.java

示例9: equals

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public boolean equals(Object o) {
    if (this == o) return true;

    if (o instanceof DiskFileKey) {

        DiskFileKey key = (DiskFileKey) o;

        if (hashCode != key.hashCode) return false;
        FileObject fo2 = key.fileObject;
        FileObject fo = fileObject;

        if (fo == fo2) return true;

        try {
            FileSystem fs = fo.getFileSystem();
            FileSystem fs2 = fo2.getFileSystem();
            if (fs.equals(fs2)) {
                return fo.equals(fo2);
            } else {
                // fallback use absolute paths (cache them)
                if (absolutePath == null) {
                    File f = FileUtil.toFile(fo);
                    absolutePath = f.getAbsolutePath();
                }
                if (key.absolutePath == null) {
                    File f2 = FileUtil.toFile(fo2);
                    key.absolutePath = f2.getAbsolutePath();
                }
                return absolutePath.equals(key.absolutePath);
            }
        } catch (FileStateInvalidException e) {
            ErrorManager err = ErrorManager.getDefault();
            err.notify(e);
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:DiskFileKey.java

示例10: findVersion

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private String findVersion(FileObject ownerRoot) {
    try {
        if (ownerRoot != null) { //NOI18N
            if (ownerRoot.getFileSystem() instanceof JarFileSystem) {
                JarFileSystem jarFileSystem = (JarFileSystem) ownerRoot.getFileSystem();
                return SpringUtilities.getImplementationVersion(jarFileSystem);
            }
        }
    } catch (FileStateInvalidException e) {
        Exceptions.printStackTrace(e);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:OpenTagCompletionProvider.java

示例11: SnippetFileSystem

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public SnippetFileSystem(FileObject projectRoot, FileObject configRoot, String projectFSPathPrefix, String configFSPathPrefix) throws IOException {
    super(new FileSystem[] {
        projectRoot.getFileSystem(),
        configRoot.getFileSystem()
    });
    this.projectRoot = projectRoot;
    this.projectFileSystem = projectRoot.getFileSystem();
    this.configFileSystem = configRoot.getFileSystem();
    this.configRoot = configRoot;
    this.projectRootPath = projectRoot.getPath();
    this.projectFSPrefix = projectFSPathPrefix;
    this.configFSPathPrefix = configFSPathPrefix;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:SnippetFileSystem.java

示例12: testDeleteNoParent

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testDeleteNoParent() throws IOException {
    FileObject parent = FileBasedFileSystem.getFileObject(testFile).getParent();
    FileObject fobj = FileBasedFileSystem.getFileObject(testFile);
    assertNotNull(fobj);
    //parent not exists + testFile not exists
    EventsEvaluator ev = new EventsEvaluator(fobj.getFileSystem());
    Reference<FileObject> ref = new WeakReference<FileObject>(parent);
    parent = null;
    assertGC("", ref);                                
    fobj.delete();
    ev.assertDeleted(1);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:FolderObjTest.java

示例13: extractZip

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static void extractZip(final FileObject fo, final InputStream is)
throws IOException {
    FileSystem fs = fo.getFileSystem();

    fs.runAtomicAction(
        new FileSystem.AtomicAction() {
            public @Override void run() throws IOException {
                extractZipImpl(fo, is);
            }
        }
    );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:GsfUtilities.java

示例14: testAnnotator

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public void testAnnotator() throws FileStateInvalidException {
    FileObject fo = FileUtil.toFileObject(dataRootDir);
    FileSystem fs = fo.getFileSystem();
    StatusDecorator status = fs.getDecorator();
    
    Set<FileObject> sof = new HashSet<FileObject>();
    sof.add(fo);
    String annotatedName = status.annotateName("xxx", sof);
    assertEquals(annotatedName, "xxx");

    annotatedName = status.annotateName("annotate-me", sof);
    assertEquals(annotatedName, "annotate-me");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:VCSAnnotatorTest.java

示例15: createFileSystem

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
protected FileSystem[] createFileSystem(String testName, String[] resources) throws IOException {        
    setupWorkdir();
    setupUserdir();

    try {                                 
        repoinit();
    } catch (Exception ex) {
        throw new IOException(ex.getMessage());
    } 
                
    FileObjectFactory.reinitForTests();
    FileObject workFo = FileBasedFileSystem.getFileObject(getWorkDir());
    assertNotNull(workFo);
    List<File> files = new ArrayList<File>(resources.length);
    for (int i = 0; i < resources.length; i++) {            
        String res = resources[i];
        FileObject fo;
        if (res.endsWith("/")) {
            fo = FileUtil.createFolder(workFo,res);
            assertNotNull(fo);
        } else {
            fo = FileUtil.createData(workFo,res);
            assertNotNull(fo);
        }            
        files.add(FileUtil.toFile(fo));            
    }        
    commit(files, testName);
    return new FileSystem[]{workFo.getFileSystem()};
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:SvnFileSystemTest.java


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