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


Java FileUtil.urlForArchiveOrDir方法代码示例

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


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

示例1: createCompileCPI

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private ClassPathImplementation createCompileCPI(MavenProject project, File binary) {
    List<PathResourceImplementation> items = new ArrayList<PathResourceImplementation>();
    //according to jglick this could be posisble to leave out on compilation CP..
    items.add(ClassPathSupport.createResource(FileUtil.urlForArchiveOrDir(binary)));
    if (project != null) {
        for (Artifact s : project.getCompileArtifacts()) {
            File file = s.getFile();
            if (file == null) continue;
            URL u = FileUtil.urlForArchiveOrDir(file);
            if(u != null) {
                items.add(ClassPathSupport.createResource(u));
            } else {
                LOG.log(Level.FINE, "Could not retrieve URL for artifact file {0}", new Object[] {file}); // NOI18N
            }
        }
    }
    return ClassPathSupport.createClassPathImplementation(items);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:RepositoryMavenCPProvider.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: findBinaries

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
 * Find a list of URLs of binaries which will be produced from a compilation unit.
 * Result may be empty.
 */
private List<URL> findBinaries(Element compilationUnitEl) {
    List<URL> binaries = new ArrayList<URL>();
    for (Element builtToEl : XMLUtil.findSubElements(compilationUnitEl)) {
        if (!builtToEl.getLocalName().equals("built-to")) { // NOI18N
            continue;
        }
        String text = XMLUtil.findText(builtToEl);
        String textEval = evaluator.evaluate(text);
        if (textEval == null) {
            continue;
        }
        File buildProduct = helper.resolveFile(textEval);
        URL buildProductURL = FileUtil.urlForArchiveOrDir(buildProduct);
        binaries.add(buildProductURL);
    }
    return binaries;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:SourceForBinaryQueryImpl.java

示例4: testPropagatesFlags

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testPropagatesFlags() throws IOException {
    final File wd = FileUtil.normalizeFile(getWorkDir());
    final URL cp1r1 = FileUtil.urlForArchiveOrDir(new File(wd, "cp1_root1"));   //NOI18N
    final URL cp2r1 = FileUtil.urlForArchiveOrDir(new File(wd, "cp2_root1"));   //NOI18N
    final MutableClassPathImpl cpImpl1 = new MutableClassPathImpl(cp1r1);
    final MutableClassPathImpl cpImpl2 = new MutableClassPathImpl(cp2r1)
            .add(ClassPath.Flag.INCOMPLETE);
    final SelectorImpl selector = new SelectorImpl(
                ClassPathFactory.createClassPath(cpImpl1),
                ClassPathFactory.createClassPath(cpImpl2));
    final ClassPath cp = ClassPathSupport.createMultiplexClassPath(selector);
    assertEquals(0, cp.getFlags().size());
    selector.select(1);
    assertEquals(1, cp.getFlags().size());
    selector.select(0);
    assertEquals(0, cp.getFlags().size());
    cpImpl1.add(ClassPath.Flag.INCOMPLETE);
    assertEquals(1, cp.getFlags().size());
    cpImpl1.remove(ClassPath.Flag.INCOMPLETE);
    assertEquals(0, cp.getFlags().size());
    selector.select(1);
    assertEquals(1, cp.getFlags().size());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:MuxClassPathImplementationTest.java

示例5: findJavadocForNetBeansOrgModules

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
 * Find Javadoc URL for NetBeans.org modules. May return <code>null</code>.
 */
static URL findJavadocForNetBeansOrgModules(final ModuleEntry entry, File destDir) {
    File nbOrg = null;
    if (destDir.getParent() != null) {
        nbOrg = destDir.getParentFile().getParentFile();
    }
    if (nbOrg == null) {
        throw new IllegalArgumentException("ModuleEntry " + entry +  // NOI18N
                " doesn't represent nb.org module"); // NOI18N
    }
    File builtJavadoc = new File(nbOrg, "nbbuild/build/javadoc"); // NOI18N
    URL[] javadocURLs = null;
    if (builtJavadoc.exists()) {
        File[] javadocs = builtJavadoc.listFiles();
        javadocURLs = new URL[javadocs.length];
        for (int i = 0; i < javadocs.length; i++) {
            javadocURLs[i] = FileUtil.urlForArchiveOrDir(javadocs[i]);
        }
    }
    return javadocURLs == null ? null : ApisupportAntUtils.findJavadocURL(
            entry.getCodeNameBase().replace('.', '-'), javadocURLs);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:NetBeansOrgEntry.java

示例6: getRuntimeClassPath

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@NonNull
public static List<? extends URL> getRuntimeClassPath(@NonNull final File javafxRuntime) {
    Parameters.notNull("javafxRuntime", javafxRuntime); //NOI18N
    final List<URL> result = new ArrayList<URL>();
    final File lib = new File (javafxRuntime,"lib");    //NOI18N
    final File[] children = lib.listFiles(new FileFilter() {
        @Override
        public boolean accept(@NonNull final File pathname) {
            return pathname.getName().toLowerCase().endsWith(".jar");  //NOI18N
        }
    });
    if (children != null) {
        for (File f : children) {
            final URL root = FileUtil.urlForArchiveOrDir(f);
            if (root != null) {
                result.add(root);
            }
        }
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:Utils.java

示例7: createFileSourceGroup

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private static SourceGroup createFileSourceGroup (File file, Collection<? super URL> rootsList) {
    Icon icon;
    Icon openedIcon;
    String displayName;
    final URL url = FileUtil.urlForArchiveOrDir(file);
    if (url == null) {
        return null;
    }
    else if ("jar".equals(url.getProtocol())) {  //NOI18N
        icon = openedIcon = ImageUtilities.loadImageIcon(ARCHIVE_ICON, false);
        displayName = file.getName();
    }
    else {                                
        icon = getFolderIcon (false);
        openedIcon = getFolderIcon (true);
        displayName = file.getAbsolutePath();
    }
    rootsList.add (url);
    FileObject root = URLMapper.findFileObject (url);
    if (root != null) {
        return new LibrariesSourceGroup (root,displayName,icon,openedIcon);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:LibrariesNode.java

示例8: testCompletionWorks_69735

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testCompletionWorks_69735() throws Exception {
    SuiteProject suite = generateSuite("suite");
    NbModuleProject project = TestBase.generateSuiteComponent(suite, "module");
    File library = new File(getWorkDir(), "test-library-0.1_01.jar");
    createJar(library, Collections.<String,String>emptyMap(), new Manifest());
    FileObject libraryFO = FileUtil.toFileObject(library);
    FileObject yyJar = FileUtil.copyFile(libraryFO, FileUtil.toFileObject(getWorkDir()), "yy");
    
    // library wrapper
    File suiteDir = suite.getProjectDirectoryFile();
    File wrapperDirF = new File(new File(getWorkDir(), "suite"), "wrapper");
    NbModuleProjectGenerator.createSuiteLibraryModule(
            wrapperDirF,
            "yy", // 69735 - the same name as jar
            "Testing Wrapper (yy)", // display name
            "org/example/wrapper/resources/Bundle.properties",
            suiteDir, // suite directory
            null,
            new File[] { FileUtil.toFile(yyJar)} );
    
    ApisupportAntUtils.addDependency(project, "yy", null, null, true, null);
    ProjectManager.getDefault().saveProject(project);
    
    URL wrappedJar = FileUtil.urlForArchiveOrDir(new File(wrapperDirF, "release/modules/ext/yy.jar"));
    assertEquals("no sources for wrapper", 0, SourceForBinaryQuery.findSourceRoots(wrappedJar).getRoots().length);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:SourceForBinaryImplTest.java

示例9: testJavadocForExternalModules

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testJavadocForExternalModules() throws Exception {
    ClassPath.getClassPath(resolveEEP("/suite2/misc-project/src"), ClassPath.COMPILE);
    File miscJar = resolveEEPFile("/suite2/build/cluster/modules/org-netbeans-examples-modules-misc.jar");
    URL[] roots = JavadocForBinaryQuery.findJavadoc(FileUtil.urlForArchiveOrDir(miscJar)).getRoots();
    URL[] expectedRoots = new URL[] {
        FileUtil.urlForArchiveOrDir(file(suite2, "misc-project/build/javadoc/org-netbeans-examples-modules-misc")),
        // It is inside ${netbeans.home}/.. so read this.
        urlForJar(apisZip, "org-netbeans-examples-modules-misc/"),
    };
    assertEquals("correct Javadoc roots for misc", urlSet(expectedRoots), urlSet(roots));
    ClassPath.getClassPath(resolveEEP("/suite3/dummy-project/src"), ClassPath.COMPILE);
    File dummyJar = file(suite3, "dummy-project/build/cluster/modules/org-netbeans-examples-modules-dummy.jar");
    roots = JavadocForBinaryQuery.findJavadoc(FileUtil.urlForArchiveOrDir(dummyJar)).getRoots();
    expectedRoots = new URL[] {
        FileUtil.urlForArchiveOrDir(file(suite3, "dummy-project/build/javadoc/org-netbeans-examples-modules-dummy")),
    };
    assertEquals("correct Javadoc roots for dummy", urlSet(expectedRoots), urlSet(roots));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:JavadocForBinaryImplTest.java

示例10: testMissingEvents

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testMissingEvents() throws Exception {
    InstanceContent ic = new InstanceContent();
    Lookup lookup = new AbstractLookup(ic);
    ProviderImpl defaultCP = new ProviderImpl();

    final URL root1 = FileUtil.urlForArchiveOrDir(FileUtil.normalizeFile(new File(getWorkDir(),"root1")));
    final URL root2 = FileUtil.urlForArchiveOrDir(FileUtil.normalizeFile(new File(getWorkDir(),"root2")));
    final MutableCPImpl cpImpl = new MutableCPImpl(root1);

    defaultCP.paths.put(ClassPath.COMPILE, ClassPathFactory.createClassPath(cpImpl));
    ClassPathProviderMerger instance = new ClassPathProviderMerger(defaultCP);
    ClassPathProvider result = instance.merge(lookup);

    ClassPath compile = result.findClassPath(null, ClassPath.COMPILE);
    assertNotNull(compile);
    assertEquals(1, compile.entries().size());

    cpImpl.add(root2);
    assertEquals(2, compile.entries().size());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ClassPathProviderMergerTest.java

示例11: stripDefaultJavaPlatform

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private StripPlatformResult stripDefaultJavaPlatform(String[] boot) {
    StripPlatformResult res = new StripPlatformResult();
    List<URL> toRet = new ArrayList<URL>();
    res.urls = toRet;
    Set<URL> defs = getDefJavaPlatBCP();
    OUTER: for (String s : boot) {
        File f = FileUtilities.convertStringToFile(s);
        URL entry = FileUtil.urlForArchiveOrDir(f);
        if (entry != null && !defs.contains(entry)) {
            if (entry.getPath().endsWith("/jfxrt.jar!/")) {
                //we need to iterate the defs and check again as jdk8 and jdk7 have these at different places
                for (URL d : defs) {
                    if (d.getPath().endsWith("/jfxrt.jar!/")) {
                        res.hasFx = true;
                        continue OUTER;
                    }
                }
            }
            toRet.add(entry);
        }
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:EndorsedClassPathImpl.java

示例12: addZipOrFolder

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void addZipOrFolder(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addZipOrFolder
    JFileChooser chooser = new JFileChooser(ModuleUISettings.getDefault().getLastUsedNbPlatformLocation());
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    chooser.setFileFilter(new FileFilter() {
        public boolean accept(File f)  {
            return f.isDirectory() || isValidNbSourceRoot(f);
        }
        public String getDescription() {
            return getMessage("CTL_SourcesTab");
        }
    });
    int ret = chooser.showOpenDialog(this);
    if (ret == JFileChooser.APPROVE_OPTION) {
        File file = FileUtil.normalizeFile(chooser.getSelectedFile());
        if (!file.exists() || (file.isFile() && !isValidNbSourceRoot(file))) {
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                    getMessage("MSG_NotValidNBSrcZIP")));
        } else {
            URL newUrl = FileUtil.urlForArchiveOrDir(file);
            if (model.containsRoot(newUrl)) {
                DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                    getMessage("MSG_ExistingNBSrcZIP")));
            } else {
                ModuleUISettings.getDefault().setLastUsedNbPlatformLocation(file.getParentFile().getAbsolutePath());
                model.addSourceRoot(newUrl);
                sourceList.setSelectedValue(newUrl, true);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:NbPlatformCustomizerSources.java

示例13: getPlatformByDestDir

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
/**
     * Find a platform by its installation directory.
     * If there is a registered platform for that directory, returns it.
     * Otherwise will create an anonymous platform ({@link #getID} will be null).
     * An anonymous platform might have sources associated with it;
     * currently this will be true in case the dest dir is nbbuild/netbeans/ inside a netbeans.org checkout.
     * @param the installation directory (as in {@link #getDestDir})
     * @param the harness dir if known; if null, will use the harness associated with the platform (if any)
     * @return the platform with that destination directory
     */
    public static @NonNull NbPlatform getPlatformByDestDir(@NonNull File destDir, @NullAllowed File harnessDir) {
        Set<NbPlatform> plafs = getPlatformsInternal();
        synchronized (plafs) {
            for (NbPlatform p : plafs) {
                // DEBUG only
//                int dif = p.getDestDir().compareTo(destDir);

                if (p.getDestDir().equals(destDir)) {
                    return p;
                }
            }
        }
        URL[] sources = new URL[0];
        if (destDir.getName().equals("netbeans")) { // NOI18N
            File parent = destDir.getParentFile();
            if (parent != null && parent.getName().equals("nbbuild")) { // NOI18N
                File superparent = parent.getParentFile();
                if (superparent != null && ModuleList.isNetBeansOrg(superparent)) {
                    sources = new URL[] {FileUtil.urlForArchiveOrDir(superparent)};
                }
            }
        }
        // XXX might also check OpenProjectList for NbModuleProject's and/or SuiteProject's with a matching
        // dest dir and look up property 'sources' to use; TBD whether Javadoc could also be handled in a
        // similar way
        return new NbPlatform(null, null, destDir, harnessDir != null ? harnessDir : findHarness(destDir), sources, new URL[0]);
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:NbPlatform.java

示例14: fileToURL

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private static URL fileToURL (File file, Project project, boolean reportNonExistingFiles, boolean withSlash) {
    FileObject fileObject = FileUtil.toFileObject (file);
    if (fileObject == null) {
        if (reportNonExistingFiles) {
            String path = file.getAbsolutePath();
            project.log("Have no file for "+path, Project.MSG_WARN);
        }
        return null;
    }
    if (FileUtil.isArchiveFile (fileObject)) {
        fileObject = FileUtil.getArchiveRoot (fileObject);
        if (fileObject == null) {
            project.log("Bad archive "+file.getAbsolutePath(), Project.MSG_WARN);
            /*
            ErrorManager.getDefault().notify(ErrorManager.getDefault().annotate(
                    new NullPointerException("Bad archive "+file.toString()),
                    NbBundle.getMessage(JPDAStart.class, "MSG_WrongArchive", file.getAbsolutePath())));
             */
            return null;
        }
    }
    if (withSlash) {
        return FileUtil.urlForArchiveOrDir(file);
    } else {
        return fileObject.toURL ();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:JPDAStart.java

示例15: doTestFindSourceRootForCompiledClasses

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void doTestFindSourceRootForCompiledClasses(String srcPath, String classesPath) throws Exception {
    File classesF = file(classesPath);
    File srcF = file(srcPath);
    FileObject src = FileUtil.toFileObject(srcF);
    assertNotNull("have " + srcF, src);
    URL u = FileUtil.urlForArchiveOrDir(classesF);
    assertEquals("right source root for " + u,
        Collections.singletonList(src),
        trimGenerated(Arrays.asList(SourceForBinaryQuery.findSourceRoots(u).getRoots())));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:SourceForBinaryImplTest.java


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