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


Java FileUtil.getArchiveFile方法代码示例

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


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

示例1: getOwningBinaryRoot

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
Pair<URL, FileObject> getOwningBinaryRoot(final FileObject fo) {
    if (fo == null) {
        return null;
    }
    final String foPath = fo.toURL().getPath();
    List<URL> clone = new ArrayList<>(this.scannedBinaries2InvDependencies.keySet());
    for (URL root : clone) {
        URL fileURL = FileUtil.getArchiveFile(root);
        boolean archive = true;
        if (fileURL == null) {
            fileURL = root;
            archive = false;
        }
        String filePath = fileURL.getPath();
        if (filePath.equals(foPath)) {
            return Pair.of(root, null);
        }
        if (!archive && foPath.startsWith(filePath)) {
            return Pair.of(root, null);
        }
    }

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

示例2: findForCPExt

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
 * Find Javadoc roots for classpath extensions ("wrapped" JARs) of the project
 * added by naming convention <tt>&lt;jar name&gt;-javadoc(.zip)</tt>
 * See issue #66275
 * @param binaryRoot
 * @return
 */
private Result findForCPExt(URL binaryRoot) {
    URL jar = FileUtil.getArchiveFile(binaryRoot);
    if (jar == null)
        return null;    // not a class-path-extension
    File binaryRootF = Utilities.toFile(URI.create(jar.toExternalForm()));
    // XXX this will only work for modules following regular naming conventions:
    String n = binaryRootF.getName();
    if (!n.endsWith(".jar")) { // NOI18N
        // ignore
        return null;
    }
    // convention-over-cfg per mkleint's suggestion: <jarname>-javadoc(.zip) folder or ZIP
    File jFolder = new File(binaryRootF.getParentFile(), 
            n.substring(0, n.length() - ".jar".length()) + "-javadoc");
    if (jFolder.isDirectory()) {
            return new R(new URL[]{FileUtil.urlForArchiveOrDir(jFolder)});
    } else {
        File jZip = new File(jFolder.getAbsolutePath() + ".zip");
        if (jZip.isFile()) {
            return new R(new URL[]{FileUtil.urlForArchiveOrDir(jZip)});
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:JavadocForBinaryImpl.java

示例3: getAbsolutePath

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public String getAbsolutePath(FileObject fileObject) {
    String fileName = getNativePath(fileObject);
    //support selected items in jars
    if (null != FileUtil.getArchiveFile(fileObject)) {
        String fullJARPath
                = getNativePath(FileUtil.getArchiveFile(fileObject));
        String archiveFileName = fileObject.getPath();
        if (!archiveFileName.isEmpty()) {
            fileName = fullJARPath + File.pathSeparator
                    + archiveFileName;
        } else {
            fileName = fullJARPath;
        }
    }
    return fileName;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:CopyPathToClipboardAction.java

示例4: getOwner

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
 * Find the project, if any, which "owns" the given file.
 * @param file the file (generally on disk)
 * @return a project which contains it, or null if there is no known project containing it
 */
public static Project getOwner(FileObject file) {
    if (file == null) {
        throw new NullPointerException("Passed null to FileOwnerQuery.getOwner(FileObject)"); // NOI18N
    }
    FileObject archiveRoot = FileUtil.getArchiveFile(file);
    if (archiveRoot != null) {
        file = archiveRoot;
    }
    for (FileOwnerQueryImplementation q : getInstances()) {
        Project p = q.getOwner(file);
        if (p != null) {
            if (LOG.isLoggable(Level.FINE)) {
                LOG.log(Level.FINE, "getOwner({0}) -> {1} @{2} from {3}", new Object[] {file, p, p.hashCode(), q});
            }
            return p == UNOWNED ? null : p;
        }
    }
    LOG.log(Level.FINE, "getOwner({0}) -> nil", file);
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:FileOwnerQuery.java

示例5: apply

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Override
public Boolean apply(@NonNull final URL url) {
    final URL aurl = FileUtil.isArchiveArtifact(url) ?
            FileUtil.getArchiveFile(url) :
            url;
    if (Optional.ofNullable(includeProp)
            .map((p) -> getDir(p))
            .map((fo) -> Objects.equals(fo.toURL(),aurl))
            .orElse(Boolean.FALSE)) {
        return Boolean.TRUE;
    }            
    if(Optional.ofNullable(excludeProp)
            .map((p) -> getDir(p))
            .map((fo) -> Objects.equals(fo.toURL(),aurl))
            .orElse(Boolean.FALSE)) {
        return Boolean.FALSE;
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ClassPathProviderImpl.java

示例6: validateNbinstURL

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void validateNbinstURL(URL u, TestHandler handler, FileObject f) {
    URL u2 = FileUtil.getArchiveFile(u);
    if (u2 != null) {
        u = u2;
    }
    if ("nbinst".equals(u.getProtocol())) {
        List<String> errors = handler.errors();
        try {
            int len = errors.size();
            u.openStream().close();
            if (errors.size() == len + 1) {
                errors.set(len, f.getPath() + ": " + errors.get(len));
            }
        } catch (IOException x) {
            errors.add(f.getPath() + ": cannot open " + u + ": " + x);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ValidateNbinstTest.java

示例7: classPathURIs

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@NonNull
private static Set<URI> classPathURIs(@NullAllowed final ClassPath cp) {
    final Set<URI> res = new HashSet<>();
    if (cp != null) {
        for (ClassPath.Entry e : cp.entries()) {
            try {
                final URL rootUrl = e.getURL();
                URL fileURL = FileUtil.getArchiveFile(rootUrl);
                if (fileURL == null) {
                    fileURL = rootUrl;
                }
                res.add(fileURL.toURI());
            } catch (URISyntaxException ex) {
                LOG.log(
                        Level.WARNING,
                        "Cannot convert to URI: {0}, reason: {1}",  //NOI18N
                        new Object[]{
                            e.getURL(),
                            ex.getMessage()
                        });
            }
        }
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ProjectOperations.java

示例8: addBinary

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@org.netbeans.api.annotations.common.SuppressWarnings(
value="DMI_COLLECTION_OF_URLS",
justification="URLs have never host part")
synchronized boolean addBinary(@NonNull final URL root) {
    if (binariesListener != null && !binaryRoots.containsKey(root)) {
        File f = null;
        final URL archiveUrl = FileUtil.getArchiveFile(root);
        try {
            final URI uri = archiveUrl != null ? archiveUrl.toURI() : root.toURI();
            if (uri.getScheme().equals("file")) { //NOI18N
                f = BaseUtilities.toFile(uri);
            }
        } catch (URISyntaxException use) {
            LOG.log (
                Level.INFO,
                "Can't convert: {0} to java.io.File, due to: {1}, (archive url: {2}).", //NOI18N
                new Object[]{
                    root,
                    use.getMessage(),
                    archiveUrl
                });
        }
        if (f != null) {
            if (archiveUrl != null) {
                // listening on an archive file
                safeAddFileChangeListener(binariesListener, f);
            } else {
                // listening on a folder
                safeAddRecursiveListener(binariesListener, f, null);
            }
            binaryRoots.put(root, Pair.of(f, archiveUrl != null));
        }
    }
    return listens;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:RootsListener.java

示例9: getKeys

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private List<SourceGroup> getKeys () {
    final FileObject[] roots = ((PlatformNode)this.getNode()).pp.getBootstrapLibraries();
    if (roots.length == 0) {
        return Collections.<SourceGroup>emptyList();
    }
    final List<SourceGroup> result = new ArrayList<>(roots.length);
    for (FileObject root : roots) {
            FileObject file;
            Icon icon;
            Icon openedIcon;
            switch (root.toURL().getProtocol()) {
                case "jar":
                    file = FileUtil.getArchiveFile (root);
                    icon = openedIcon = ImageUtilities.loadImageIcon(ARCHIVE_ICON, false);
                    break;
                case "nbjrt":
                    file = root;
                    icon = openedIcon = ImageUtilities.loadImageIcon(MODULE_ICON, false);
                    break;
                default:
                    file = root;
                    icon = openedIcon = null;
            }
            if (file.isValid()) {
                result.add (new LibrariesSourceGroup(root,file.getNameExt(),icon, openedIcon));
            }
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:PlatformNode.java

示例10: noJavadocFound

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private String noJavadocFound() {
    if (handle != null) {
        final List<ClassPath> cps = new ArrayList<>(2);
        ClassPath cp = cpInfo.getClassPath(ClasspathInfo.PathKind.BOOT);
        if (cp != null) {
            cps.add(cp);
        }
        cp = cpInfo.getClassPath(ClasspathInfo.PathKind.COMPILE);
        if (cp != null) {
            cps.add(cp);
        }
        cp = ClassPathSupport.createProxyClassPath(cps.toArray(new ClassPath[cps.size()]));
        String toSearch = SourceUtils.getJVMSignature(handle)[0].replace('.', '/');
        if (handle.getKind() != ElementKind.PACKAGE) {
            toSearch += ".class"; //NOI18N
        }
        final FileObject resource = cp.findResource(toSearch);
        if (resource != null) {
            final FileObject root = cp.findOwnerRoot(resource);
            try {
                final URL rootURL = root.getURL();
                if (JavadocForBinaryQuery.findJavadoc(rootURL).getRoots().length == 0) {
                    FileObject userRoot = FileUtil.getArchiveFile(root);
                    if (userRoot == null) {
                        userRoot = root;
                    }
                    return NbBundle.getMessage(
                            ElementJavadoc.class,
                            "javadoc_content_not_found_attach",
                            rootURL.toExternalForm(),
                            FileUtil.getFileDisplayName(userRoot));
                }
            } catch (FileStateInvalidException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    }
    return NbBundle.getMessage(ElementJavadoc.class, "javadoc_content_not_found"); //NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:ElementJavadoc.java

示例11: findForBinaryRoot

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private Result findForBinaryRoot(final URL binaryRoot) throws MalformedURLException, MalformedURLException {
    URL jar = FileUtil.getArchiveFile(binaryRoot);
    if (!jar.getProtocol().equals("file")) { // NOI18N
        Util.err.log(binaryRoot + " is not an archive file."); // NOI18N
        return null;
    }
    File binaryRootF = Utilities.toFile(URI.create(jar.toExternalForm()));
    // XXX this will only work for modules following regular naming conventions:
    String n = binaryRootF.getName();
    if (!n.endsWith(".jar")) { // NOI18N
        Util.err.log(binaryRootF + " is not a *.jar"); // NOI18N
        return null;
    }
    String cnbdashes = n.substring(0, n.length() - 4);
    NbPlatform supposedPlaf = null;
    for (NbPlatform plaf : NbPlatform.getPlatformsOrNot()) {
        if (binaryRootF.getAbsolutePath().startsWith(plaf.getDestDir().getAbsolutePath() + File.separator)) {
            supposedPlaf = plaf;
            break;
        }
    }
    if (supposedPlaf == null) {
        // try external clusters
        URL[] javadocRoots = ModuleList.getJavadocRootsForExternalModule(binaryRootF);
        if (javadocRoots.length > 0) {
            return findByDashedCNB(cnbdashes, javadocRoots, true);
        }
        Util.err.log(binaryRootF + " does not correspond to a known platform"); // NOI18N
        return null;
    }
    Util.err.log("Platform in " + supposedPlaf.getDestDir() + " claimed to have Javadoc roots "
        + Arrays.asList(supposedPlaf.getJavadocRoots()));
    return findByDashedCNB(cnbdashes, supposedPlaf.getJavadocRoots(), true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:GlobalJavadocForBinaryImpl.java

示例12: isFromLibrary

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
 * @param element
 * @param info
 * @return true if given element comes from library
 */
public static boolean isFromLibrary(ElementHandle<? extends Element> element, ClasspathInfo info) {
    FileObject file = SourceUtils.getFile(element, info);
    if (file == null) {
        //no source for given element. Element is from library
        return true;
    }
    return FileUtil.getArchiveFile(file) != null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:RefactoringUtils.java

示例13: toString

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Override
public String toString() {
    String begin = "<html>";
    String end = "</html>";
    if (!userRecord) {
        begin += "<b>";
        end = "</b>" + end;
    }
    URL tmp = url;
    if ("jar".equals(tmp.getProtocol())) {      //NOI18N
        URL fileURL = FileUtil.getArchiveFile(tmp);
        if (FileUtil.getArchiveRoot(fileURL).equals(tmp)) {
            // really the root
            tmp = fileURL;
        } else {
            // some subdir, just show it as is
            FileObject fo = URLMapper.findFileObject(tmp);
            if (fo == null || !fo.isValid()) {
                begin += "<font color=#DF0101>";
                end = "</font>" + end;
            }
            return begin + tmp.toExternalForm() + end;
        }
    }
    if ("file".equals(tmp.getProtocol())) {
        File f = Utilities.toFile(URI.create(tmp.toExternalForm()));
        if (!f.exists()) {
            begin += "<font color=#DF0101>";
            end = "</font>" + end;
        }
        return begin + f.getAbsolutePath() + end;
    } else {
        return begin + tmp.toExternalForm() + end;
    }
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:36,代码来源:AndroidPlatformInfo.java

示例14: disableErrors

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public static Set<Severity> disableErrors(FileObject file) {
    if (file.getAttribute(DISABLE_ERRORS) != null) {
        return EnumSet.allOf(Severity.class);
    }
    if (!file.canWrite() && FileUtil.getArchiveFile(file) != null) {
        return EnumSet.allOf(Severity.class);
    }

    return EnumSet.noneOf(Severity.class);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:Utilities.java

示例15: newUpdateCopyLibsAction

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@NonNull
private Runnable newUpdateCopyLibsAction() {
    return new Runnable() {
        private final String LIB_COPY_LIBS = "CopyLibs"; //NOI18N
        private final String PROP_VERSION = "version";   //NOI18N
        private final String VOL_CP = "classpath";       //NOI18N

        @Override
        public void run() {
            final LibraryManager projLibManager = refHelper.getProjectLibraryManager();
            if (projLibManager == null) {
                return;
            }
            final Library globalCopyLibs = LibraryManager.getDefault().getLibrary(LIB_COPY_LIBS);
            final Library projectCopyLibs = projLibManager.getLibrary(LIB_COPY_LIBS);
            if (globalCopyLibs == null || projectCopyLibs == null) {
                return;
            }
            final String globalStr = globalCopyLibs.getProperties().get(PROP_VERSION);
            if (globalStr == null) {
                return;
            }
            try {
                final SpecificationVersion globalVersion = new SpecificationVersion(globalStr);
                final String projectStr = projectCopyLibs.getProperties().get(PROP_VERSION);
                if (projectStr != null && globalVersion.compareTo(new SpecificationVersion(projectStr)) <= 0) {
                    return;
                }

                final List<URL> content = projectCopyLibs.getContent(VOL_CP);
                projLibManager.removeLibrary(projectCopyLibs);
                final FileObject projLibLoc = URLMapper.findFileObject(projLibManager.getLocation());
                if (projLibLoc != null) {
                    final FileObject libFolder = projLibLoc.getParent();
                    boolean canDelete = libFolder.canWrite();
                    FileObject container = null;
                    for (URL u : content) {
                        FileObject fo = toFile(u);
                        if (fo != null) {
                            canDelete &= fo.canWrite();
                            if (container == null) {
                                container = fo.getParent();
                                canDelete &= container.canWrite();
                                canDelete &= LIB_COPY_LIBS.equals(container.getName());
                                canDelete &= libFolder.equals(container.getParent());
                            } else {
                                canDelete &= container.equals(fo.getParent());
                            }
                        }
                    }
                    if (canDelete && container != null) {
                        container.delete();
                    }
                }
                refHelper.copyLibrary(globalCopyLibs);

            } catch (IllegalArgumentException iae) {
                LOG.log(
                        Level.WARNING,
                        "Cannot update {0} due to invalid version.", //NOI18N
                        projectCopyLibs.getDisplayName());
            } catch (IOException ioe) {
                Exceptions.printStackTrace(ioe);
            }
        }

        @CheckForNull
        private FileObject toFile(@NonNull final URL url) {
            final URL file = FileUtil.getArchiveFile(url);
            return URLMapper.findFileObject(file != null ? file : url);
        }
    };
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:74,代码来源:J2SEProject.java


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