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


Java FileObject.canRead方法代码示例

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


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

示例1: accept

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@NonNull
Collection<? extends URI> accept(@NonNull final FileObject fo) {
    if (fo.canRead() && fo.isData()) {
        final String nameExt = fo.getNameExt();
        if (DOCS_FILE_PATTERN.matcher(nameExt).matches() && JAVAFX_FILE_PATTERN.matcher(nameExt).matches()) {
            final FileObject root = FileUtil.getArchiveRoot(fo);
            if (root != null) {
                final List<URI> roots = new ArrayList<>(DOCS_PATHS.size());
                for (String path : DOCS_PATHS) {
                    final FileObject docRoot = root.getFileObject(path);
                    if (docRoot != null) {
                        roots.add(docRoot.toURI());
                    }
                }
                return Collections.unmodifiableCollection(roots);
            }
        }
    }
    return Collections.emptySet();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:JavaFxDefaultJavadocImpl.java

示例2: getAdditionalClassPath

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private ClassPath getAdditionalClassPath(File baseDir) {
    try {
        String root = BaseUtilities.toURI(baseDir).toURL().toExternalForm();
        Properties sourcesProperties = Properties.getDefault ().getProperties ("debugger").getProperties ("sources");
        List<String> additionalSourceRoots = (List<String>) sourcesProperties.
                getProperties("additional_source_roots").
                getMap("project", Collections.emptyMap()).
                get(root);
        if (additionalSourceRoots == null || additionalSourceRoots.isEmpty()) {
            return null;
        }
        List<FileObject> additionalSourcePath = new ArrayList<FileObject>(additionalSourceRoots.size());
        for (String ar : additionalSourceRoots) {
            FileObject fo = getFileObject(ar);
            if (fo != null && fo.canRead()) {
                additionalSourcePath.add(fo);
            }
        }
        this.additionalSourceRoots = new LinkedHashSet<String>(additionalSourceRoots);
        return createClassPath(
                additionalSourcePath.toArray(new FileObject[0]));
    } catch (MalformedURLException ex) {
        Exceptions.printStackTrace(ex);
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:SourcePathProviderImpl.java

示例3: getAdditionalRemoteClassPath

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private List<FileObject> getAdditionalRemoteClassPath() {
    Properties sourcesProperties = Properties.getDefault ().getProperties ("debugger").getProperties ("sources");
    List<String> additionalSourceRoots = (List<String>) sourcesProperties.
            getProperties("additional_source_roots").
            getCollection("src_roots", Collections.emptyList());
    if (additionalSourceRoots == null || additionalSourceRoots.isEmpty()) {
        return null;
    }
    List<FileObject> additionalSourcePath = new ArrayList<FileObject>(additionalSourceRoots.size());
    for (String ar : additionalSourceRoots) {
        FileObject fo = getFileObject(ar);
        if (fo != null && fo.canRead()) {
            additionalSourcePath.add(fo);
        }
    }
    this.additionalSourceRoots = new LinkedHashSet<String>(additionalSourceRoots);
    return additionalSourcePath;
    //return ClassPathSupport.createClassPath(
    //        additionalSourcePath.toArray(new FileObject[0]));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:SourcePathProviderImpl.java

示例4: createClassPath

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static ClassPath createClassPath(FileObject[] froots) {
    List<PathResourceImplementation> pris = new ArrayList<PathResourceImplementation> ();
    for (FileObject fo : froots) {
        if (fo != null && fo.canRead()) {
            try {
                URL url = fo.toURL();
                pris.add(ClassPathSupport.createResource(url));
            } catch (IllegalArgumentException iaex) {
                // Can be thrown from ClassPathSupport.createResource()
                // Ignore - bad source root
                //logger.log(Level.INFO, "Invalid source root = "+fo, iaex);
                logger.warning(iaex.getLocalizedMessage());
            }
        }
    }
    return ClassPathSupport.createClassPath(pris);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:SourcePathProviderImpl.java

示例5: getFreshInvalidityStatus

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
 * Check validity status of this item.
 * 
 * @return  an invalidity status of this item if it is invalid,
 *          or {@code null} if this item is valid
 * @author  Tim Boudreau
 * @author  Marian Petras
 */
private InvalidityStatus getFreshInvalidityStatus() {
    log(FINER, "getInvalidityStatus()");                            //NOI18N
    FileObject f = getFileObject();
    if (!f.isValid()) {
        log(FINEST, " - DELETED");            
        return InvalidityStatus.DELETED;
    }
    if (f.isFolder()) {
        log(FINEST, " - BECAME_DIR");            
        return InvalidityStatus.BECAME_DIR;
    }
    
    long stamp = f.lastModified().getTime();
    if ((!refreshed && stamp > resultModel.getStartTime())
            || (refreshed && stamp > timestamp)) {
        log(SEVERE, "file's timestamp changed since start of the search");
        if (LOG.isLoggable(FINEST)) {
            final java.util.Calendar cal = java.util.Calendar.getInstance();
            cal.setTimeInMillis(stamp);
            log(FINEST, " - file stamp:           " + stamp + " (" + cal.getTime() + ')');
            cal.setTimeInMillis(resultModel.getStartTime());
            log(FINEST, " - result model created: " + resultModel.getStartTime() + " (" + cal.getTime() + ')');
        }            
        return InvalidityStatus.CHANGED;
    }
    
    if (f.getSize() > Integer.MAX_VALUE) {            
        return InvalidityStatus.TOO_BIG;
    }
    
    if (!f.canRead()) {           
        return InvalidityStatus.CANT_READ;
    }
    
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:45,代码来源:MatchingObject.java

示例6: getSources

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@NonNull
private static FileObject[] getSources(@NonNull final Collection<? extends FileObject> installFolders) {
    if (installFolders.isEmpty()) {
        return new FileObject[0];
    }
    final FileObject installFolder = installFolders.iterator().next();
    if (installFolder == null || !installFolder.isValid()) {
        return new FileObject[0];
    }
    FileObject src = installFolder.getFileObject("src.zip");    //NOI18N
    if (src == null) {
        src = installFolder.getFileObject("src.jar");    //NOI18N
    }
    if (src == null || !src.canRead()) {
        return new FileObject[0];
    }
    FileObject root = FileUtil.getArchiveRoot(src);
    if (root == null) {
        return new FileObject[0];
    }
    if (Utilities.getOperatingSystem() == Utilities.OS_MAC) {
        FileObject reloc = root.getFileObject("src");   //NOI18N
        if (reloc != null) {
            root = reloc;
        }
    }
    return new FileObject[]{root};
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:FallbackDefaultJavaPlatform.java

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

示例8: readRules

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/** Read rules from system filesystem */
    private static List<Pair<Rule,FileObject>> readRules( FileObject folder ) {

        List<Pair<Rule,FileObject>> rules = new LinkedList<Pair<Rule,FileObject>>();
        
        if (folder == null) {
            return rules;
        }

        //HashMap<FileObject,DefaultMutableTreeNode> dir2node = new HashMap<FileObject,DefaultMutableTreeNode>();

//        // XXX Probably not he best order
//        Enumeration e = folder.getData( true );
        
        Enumeration<FileObject> e = Collections.enumeration(getSortedDataRecursively(folder));
        while( e.hasMoreElements() ) {
            FileObject o = e.nextElement();
            String name = o.getNameExt().toLowerCase();

            if ( o.canRead() ) {
                Rule r = null;
                if ( name.endsWith( INSTANCE_EXT ) ) {
                    r = instantiateRule(o);
                }
                if ( r != null ) {
                    rules.add( Pair.<Rule,FileObject>of( r, o ) );
                }
            }
        }
        Collections.sort(rules, new Comparator<Pair<Rule,FileObject>>() {
            @Override
            public int compare(Pair<Rule,FileObject> p1, Pair<Rule,FileObject> p2) {
                return p1.first().getDisplayName().compareTo(p2.first().getDisplayName());
            }
        });
        return rules;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:GsfHintsManager.java

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

示例10: reparseNowBlocking

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
 * Reparses file. 
 *
 * @param  fire  true if should fire changes
 */
private PropertiesStructure reparseNowBlocking(boolean fire) {
    PropertiesStructure propStructure = null;
    synchronized (this) {
        if (!parsingAllowed) {
            return null;
        }

        FileObject fo = propFileEntry.getFile();
        if(!fo.canRead()) {
            // whatever happend - the file does not exist
            // so don't even try to parse it
            // XXX may be a HACK. see issue #63321. This is supposed to be
            // rewriten after 6.0.
            return null;
        }
        PropertiesParser parser = new PropertiesParser(propFileEntry);

        try {
            parserWRef = new WeakReference<PropertiesParser>(parser);

            parser.initParser();
            propStructure = parser.parseFile();

        } catch (IOException ioe) {
            // di do prdele
        } finally {
            parser.clean();
        }
    }
    updatePropertiesStructure(propStructure, fire);
    return propStructure;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:StructHandler.java

示例11: getSourceRoot

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
 * Returns the source root (if any) for given url.
 *
 * @param url a url of resource file
 *
 * @return the source root or <code>null</code> when no source root was found.
 */
@Override
public synchronized String getSourceRoot(String url) {
    FileObject fo;
    try {
        fo = URLMapper.findFileObject(new java.net.URL(url));
    } catch (java.net.MalformedURLException ex) {
        fo = null;
    }
    FileObject[] roots = null;
    if (fo != null && fo.canRead()) {
        ClassPath cp = ClassPath.getClassPath(fo, ClassPath.SOURCE);
        if (cp != null) {
            roots = cp.getRoots();
        }
    }
    if (roots == null) {
        roots = originalSourcePath.getRoots();
    }
    for (FileObject fileObject : roots) {
        String rootURL = fileObject.toURL().toString();
        if (url.startsWith(rootURL)) {
            String root = getRoot(fileObject);
            if (root != null) {
                return root;
            }
        }
    }
    return null; // not found
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:SourcePathProviderImpl.java

示例12: handleIOException

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/** #26521, 114976 - ignore not readable and windows' locked files. */
private static void handleIOException(FileObject fo, IOException ioe) throws IOException {
    if (fo.canRead()) {
        if (!BaseUtilities.isWindows() || !(ioe instanceof FileNotFoundException) || !fo.isValid() || !fo.getName().toLowerCase().contains("ntuser")) {//NOI18N
            throw ioe;
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:FileElement.java

示例13: readRules

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/** Read rules from system filesystem */
private static List<Pair<POMErrorFixBase, FileObject>> readRules( FileObject folder ) {
    List<Pair<POMErrorFixBase,FileObject>> rules = new LinkedList<Pair<POMErrorFixBase,FileObject>>();
    
    if (folder == null) {
        return rules;
    }

    Queue<FileObject> q = new LinkedList<FileObject>();
    
    q.offer(folder);
    
    while(!q.isEmpty()) {
        FileObject o = q.poll();
        
        if (o.isFolder()) {
            q.addAll(Arrays.asList(o.getChildren()));
            continue;
        }
        
        if (!o.isData()) {
            continue;
        }
        
        String name = o.getNameExt().toLowerCase();

        if ( o.canRead() ) {
            POMErrorFixBase r = null;
            if ( name.endsWith( INSTANCE_EXT ) ) {
                r = instantiateRule(o);
            }
            if ( r != null ) {
                rules.add( Pair.<POMErrorFixBase,FileObject>of( r, o ) );
            }
        }
    }
    return rules;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:RulesManager.java

示例14: accept

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@NonNull
Collection<? extends URI> accept(@NonNull FileObject fo) {
    if (fo.canRead()) {
        if (fo.isFolder()) {
            if ("docs".equals(fo.getName())) {  //NOI18N
                return Collections.singleton(fo.toURI());
            }
        } else if (fo.isData()) {
            final String nameExt = fo.getNameExt();
            final String vendorPath = VENDOR_DOCS.get(nameExt);
            if (vendorPath != null) {
                if (FileUtil.isArchiveFile(fo)) {
                    try {
                        return Collections.singleton(
                            new URL (FileUtil.getArchiveRoot(fo.toURL()).toExternalForm() + vendorPath).toURI());
                    } catch (MalformedURLException | URISyntaxException e) {
                        LOG.log(
                            Level.INFO,
                            "Invalid Javadoc URI for file : {0}, reason: {1}",
                            new Object[]{
                                FileUtil.getFileDisplayName(fo),
                                e.getMessage()
                        });
                        //pass
                    }
                }
            } else if (DOCS_FILE_PATTERN.matcher(nameExt).matches() && !JAVAFX_FILE_PATTERN.matcher(nameExt).matches()) {
                final FileObject root = FileUtil.getArchiveRoot(fo);
                if (root != null) {
                    final List<URI> roots = new ArrayList<>(DOCS_PATHS.size());
                    for (String path : DOCS_PATHS) {
                        final FileObject docRoot = root.getFileObject(path);
                        if (docRoot != null) {
                            roots.add(docRoot.toURI());
                        }
                    }
                    return Collections.unmodifiableCollection(roots);
                }
            }
        }
    }
    return Collections.emptySet();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:44,代码来源:J2SEPlatformDefaultJavadocImpl.java

示例15: readRules

import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/** Read rules from system filesystem */
private List<Pair<Rule,FileObject>> readRules( FileObject folder ) {
    List<Pair<Rule,FileObject>> rules = new LinkedList<Pair<Rule,FileObject>>();
    
    if (folder == null) {
        return rules;
    }

    Queue<FileObject> q = new LinkedList<FileObject>();
    
    q.offer(folder);
    
    while(!q.isEmpty()) {
        FileObject o = q.poll();
        
        o.removeFileChangeListener(this);
        o.addFileChangeListener(this);
        
        if (o.isFolder()) {
            q.addAll(Arrays.asList(o.getChildren()));
            continue;
        }
        
        if (!o.isData()) {
            continue;
        }
        
        String name = o.getNameExt().toLowerCase();

        if ( o.canRead() ) {
            Rule r = null;
            if ( name.endsWith( INSTANCE_EXT ) ) {
                r = instantiateRule(o);
            }
            if ( r != null ) {
                rules.add( new Pair<Rule,FileObject>( r, o ) );
            }
        }
    }
    return rules;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:42,代码来源:RulesManager.java


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