當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。