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


Java URLMapper类代码示例

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


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

示例1: getRoots

import org.openide.filesystems.URLMapper; //导入依赖的package包/类
@Override
public synchronized FileObject[] getRoots () {
    if (this.cache == null) {
        // entry is not resolved so directly volume content can be searched for it:
        final Library _lib = this.lib;
        if (getResolvedURIContent(_lib, manager, J2SELibraryTypeProvider.VOLUME_TYPE_CLASSPATH).contains(entry)) {
            List<FileObject> result = new ArrayList<FileObject>();
            for (URL u : _lib.getContent(J2SELibraryTypeProvider.VOLUME_TYPE_SRC)) {
                FileObject sourceRoot = URLMapper.findFileObject(u);
                if (sourceRoot!=null) {
                    result.add (sourceRoot);
                }
            }
            this.cache = result.toArray(new FileObject[result.size()]);
        }
        else {
            this.cache = new FileObject[0];
        }
    }
    return this.cache;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:J2SELibrarySourceForBinaryQuery.java

示例2: violationsToFileObjects

import org.openide.filesystems.URLMapper; //导入依赖的package包/类
private static FileObject[] violationsToFileObjects(
        @NonNull final Collection<? extends ProfileSupport.Violation> violations,
        @NullAllowed final Filter filter,
        @NullAllowed final Map<FileObject,Collection<ProfileSupport.Violation>> violationsByFiles) {
    final Collection<FileObject> fos = new HashSet<>(violations.size());
    for (ProfileSupport.Violation v : violations) {
        final URL fileURL = v.getFile();
        if (fileURL != null) {
            final FileObject fo = URLMapper.findFileObject(fileURL);
            if (shouldProcessViolationsInSource(fo, filter)) {
                fos.add(fo);
                if (violationsByFiles != null) {
                    Collection<ProfileSupport.Violation> violationsInFile = violationsByFiles.get(fo);
                    if (violationsInFile == null) {
                        violationsInFile = new ArrayList<>();
                        violationsByFiles.put(fo, violationsInFile);
                    }
                    violationsInFile.add(v);
                }
            }
        }
    }
    return fos.toArray(new FileObject[fos.size()]);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ProfilesAnalyzer.java

示例3: getDataObject

import org.openide.filesystems.URLMapper; //导入依赖的package包/类
private static DataObject getDataObject (String url) {
    FileObject file;
    try {
        file = URLMapper.findFileObject (new URL (url));
    } catch (MalformedURLException e) {
        return null;
    }

    if (file == null) {
        return null;
    }
    try {
        return DataObject.find (file);
    } catch (DataObjectNotFoundException ex) {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:LineTranslations.java

示例4: getFileObject

import org.openide.filesystems.URLMapper; //导入依赖的package包/类
@Override
public FileObject getFileObject() {
    if (line instanceof FutureLine) {
        URL url = getURL();
        FileObject fo = URLMapper.findFileObject(url);
        if (fo != null) {
            try {
                DataObject dobj = DataObject.find(fo);
                LineCookie lineCookie = dobj.getLookup().lookup(LineCookie.class);
                if (lineCookie == null) {
                    return null;
                }
                Line l = lineCookie.getLineSet().getCurrent(getLineNumber() - 1);
                setLine(l);
            } catch (DataObjectNotFoundException ex) {
            }
        }
        return fo;
    } else {
        return line.getLookup().lookup(FileObject.class);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:LineDelegate.java

示例5: getRoot

import org.openide.filesystems.URLMapper; //导入依赖的package包/类
@CheckForNull
public FileObject getRoot() {
    synchronized (this) {
        if (cachedRoot != null) {
            return cachedRoot;
        }
    }
    final URL root = toURL(rootURI);
    final FileObject _tmp = root == null ?
            null :
            URLMapper.findFileObject(root);
    synchronized (this) {
        if (cachedRoot == null) {
            cachedRoot = _tmp;
        }
    }
    return _tmp;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:JavaTypeProvider.java

示例6: testFindUnitTest

import org.openide.filesystems.URLMapper; //导入依赖的package包/类
public void testFindUnitTest() throws Exception {
    URL[] testRoots = UnitTestForSourceQuery.findUnitTests(nbRoot());
    assertEquals("Test root for non project folder should be null", Collections.EMPTY_LIST, Arrays.asList(testRoots));
    FileObject srcRoot = nbRoot().getFileObject("apisupport.project");
    testRoots = UnitTestForSourceQuery.findUnitTests(srcRoot);
    assertEquals("Test root for project should be null", Collections.EMPTY_LIST, Arrays.asList(testRoots));
    srcRoot = nbRoot().getFileObject("apisupport.project/test/unit/src");
    testRoots = UnitTestForSourceQuery.findUnitTests(srcRoot);
    assertEquals("Test root for tests should be null", Collections.EMPTY_LIST, Arrays.asList(testRoots));
    srcRoot = nbRoot().getFileObject("apisupport.project/src");
    testRoots = UnitTestForSourceQuery.findUnitTests(srcRoot);
    assertEquals("Test root defined", 1, testRoots.length);
    assertTrue("Test root exists", Utilities.toFile(URI.create(testRoots[0].toExternalForm())).exists());
    assertEquals("Test root", URLMapper.findFileObject(testRoots[0]), nbRoot().getFileObject("apisupport.project/test/unit/src"));
    assertEquals("One test for this project", 1, UnitTestForSourceQuery.findUnitTests(nbRoot().getFileObject("openide.windows/src")).length);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:UnitTestForSourceQueryImplTest.java

示例7: testFindSource

import org.openide.filesystems.URLMapper; //导入依赖的package包/类
public void testFindSource() {
    URL[] srcRoots = UnitTestForSourceQuery.findSources(nbRoot());
    assertEquals("Source root for non project folder should be null", Collections.EMPTY_LIST, Arrays.asList(srcRoots));
    FileObject testRoot = nbRoot().getFileObject("apisupport.project");
    srcRoots = UnitTestForSourceQuery.findSources(testRoot);
    assertEquals("Source root for project should be null", Collections.EMPTY_LIST, Arrays.asList(srcRoots));
    testRoot = nbRoot().getFileObject("apisupport.project/src");
    srcRoots = UnitTestForSourceQuery.findSources(testRoot);
    assertEquals("Source root for sources should be null", Collections.EMPTY_LIST, Arrays.asList(srcRoots));
    assertEquals("No sources for this project's sources", Collections.EMPTY_LIST, Arrays.asList(UnitTestForSourceQuery.findSources(nbRoot().getFileObject("openide.windows/src"))));
    testRoot = nbRoot().getFileObject("apisupport.project/test/unit/src");
    srcRoots = UnitTestForSourceQuery.findSources(testRoot);
    assertEquals("Source root defined", 1, srcRoots.length);
    assertTrue("Source root exists", Utilities.toFile(URI.create(srcRoots[0].toExternalForm())).exists());
    assertEquals("Source root", URLMapper.findFileObject(srcRoots[0]), nbRoot().getFileObject("apisupport.project/src"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:UnitTestForSourceQueryImplTest.java

示例8: testListeningToNbPlatform

import org.openide.filesystems.URLMapper; //导入依赖的package包/类
public void testListeningToNbPlatform() throws Exception {
    NbPlatform.getDefaultPlatform(); // initBuildProperties
    File nbSrcZip = generateNbSrcZip("");
    URL loadersURL = FileUtil.urlForArchiveOrDir(file("nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-loaders.jar"));
    SourceForBinaryQuery.Result res = SourceForBinaryQuery.findSourceRoots(loadersURL);
    assertNotNull("got result", res);
    ResultChangeListener resultCL = new ResultChangeListener();
    res.addChangeListener(resultCL);
    assertFalse("not changed yet", resultCL.changed);
    assertEquals("non source root", 0, res.getRoots().length);
    NbPlatform.getDefaultPlatform().addSourceRoot(FileUtil.urlForArchiveOrDir(nbSrcZip));
    assertTrue("changed yet", resultCL.changed);
    assertEquals("one source root", 1, res.getRoots().length);
    URL loadersSrcURL = new URL(FileUtil.urlForArchiveOrDir(nbSrcZip), "openide/loaders/src/");
    assertRoot(loadersURL, URLMapper.findFileObject(loadersSrcURL));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:GlobalSourceForBinaryImplTest.java

示例9: constructTrie

import org.openide.filesystems.URLMapper; //导入依赖的package包/类
private static void constructTrie(ByteArray array, List<URL> sources) throws IOException {
    SortedSet<CharSequence> data = new TreeSet<CharSequence>();

    for (URL u : sources) {
        FileObject f = URLMapper.findFileObject(u);
        u = f != null ? URLMapper.findURL(f, URLMapper.EXTERNAL) : u;
        BufferedReader in = new BufferedReader(new InputStreamReader(u.openStream(), "UTF-8"));
        
        try {
            String line;
            
            while ((line = in.readLine()) != null) {
                data.add(CharSequences.create(line));
            }
        } finally {
            //TODO: wrap in try - catch:
            in.close();
        }
    }
    
    constructTrieData(array, data);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:TrieDictionary.java

示例10: propertyChange

import org.openide.filesystems.URLMapper; //导入依赖的package包/类
@Override
public void propertyChange (PropertyChangeEvent evt) {
    String url = EditorContextBridge.getContext().getCurrentURL();
    FileObject fo;
    try {
        fo = URLMapper.findFileObject(new URL(url));
    } catch (MalformedURLException muex) {
        fo = null;
    }
    setEnabled (
        ActionsManager.ACTION_TOGGLE_BREAKPOINT,
        (EditorContextBridge.getContext().getCurrentLineNumber () >= 0) && 
        (fo != null && "text/x-java".equals(fo.getMIMEType()))  // NOI18N
        //(EditorContextBridge.getCurrentURL ().endsWith (".java"))
    );
    if ( debugger != null && 
         debugger.getState () == JPDADebugger.STATE_DISCONNECTED
    ) 
        destroy ();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:ToggleBreakpointActionProvider.java

示例11: findProjectImportedModules

import org.openide.filesystems.URLMapper; //导入依赖的package包/类
/**
 * Returns set of modules imported by the project. Adds to the passed collection
 * if not null. Module names from `required' clause will be returned
 * 
 * @param project the project
 * @param in optional; the collection
 * @return original collection or a new one with imported modules added
 */
public static Collection<String> findProjectImportedModules(Project project, Collection<String> in) {
    Collection<String> result = in != null ? in : new HashSet<>();
    if (project == null) {
        return result;
    }
    
    for (SourceGroup sg : org.netbeans.api.project.ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)) {
        if (isNormalRoot(sg)) {
            ClasspathInfo cpi = ClasspathInfo.create(sg.getRootFolder());
            ClassPath mcp = cpi.getClassPath(PathKind.COMPILE);
            
            for (FileObject r : mcp.getRoots()) {
                URL u = URLMapper.findURL(r, URLMapper.INTERNAL);
                String modName = SourceUtils.getModuleName(u);
                if (modName != null) {
                    result.add(modName);
                }
            }
        }
    }
    
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:ShellProjectUtils.java

示例12: isXmlSchema

import org.openide.filesystems.URLMapper; //导入依赖的package包/类
private static boolean isXmlSchema(String uri, String localURI) {
    // check the remote protocol, only http(s) is supported at the moment
    if (!(uri.startsWith(PROTOCOL_HTTP) || uri.startsWith(PROTOCOL_HTTPS))) {
        return false;
    }
    // check MIME type of the target:
    if (!localURI.startsWith(PROTOCOL_FILE)) {
        return false;
    }
    
    FileObject fo;
    try {
        fo = URLMapper.findFileObject(new URL(localURI));
        if (fo == null) {
            return false;
        }
    } catch (MalformedURLException ex) {
        return false;
    }
    return MIME_SCHEMA.equals(fo.getMIMEType()) || MIME_SCHEMA2.equals(fo.getMIMEType());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:AddCatalogEntryAction.java

示例13: findSourceRoots

import org.openide.filesystems.URLMapper; //导入依赖的package包/类
private List<FileObject> findSourceRoots(FileObject fo) {
    final FileObject root = getSourceRoot(fo);
    if (root != null) {
        return Collections.singletonList(root);                    
    }
    final ArrayList<FileObject> roots = new ArrayList();
    if (fo != null) {
        for (URL url : project.getSourceRoots().getRootURLs()) {
            final FileObject r = URLMapper.findFileObject(url);
            if (r != null && FileUtil.isParentOf(fo, r)) {
                roots.add(r);
            }
        }
    }
    return roots;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:J2SEModularPersistenceProvider.java

示例14: getResourceName

import org.openide.filesystems.URLMapper; //导入依赖的package包/类
@CheckForNull
private static String getResourceName (@NullAllowed final CompilationUnitTree cu) {
    if (cu instanceof JCTree.JCCompilationUnit) {
        JavaFileObject jfo = ((JCTree.JCCompilationUnit)cu).sourcefile;
        if (jfo != null) {
            URI uri = jfo.toUri();
            if (uri != null && uri.isAbsolute()) {
                try {
                    FileObject fo = URLMapper.findFileObject(uri.toURL());
                    if (fo != null) {
                        ClassPath cp = ClassPath.getClassPath(fo,ClassPath.SOURCE);
                        if (cp != null) {
                            return cp.getResourceName(fo,'.',false);
                        }
                    }
                } catch (MalformedURLException e) {
                    Exceptions.printStackTrace(e);
                }
            }
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:SourceAnalyzerFactory.java

示例15: findProjectModules

import org.openide.filesystems.URLMapper; //导入依赖的package包/类
public static Set<String>   findProjectModules(Project project, Set<String> in) {
    Set<String> result = in != null ? in : new HashSet<>();
    if (project == null) {
        return result;
    }
    
    for (SourceGroup sg : org.netbeans.api.project.ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)) {
        if (isNormalRoot(sg)) {
            FileObject fo = sg.getRootFolder().getFileObject("module-info.java");
            if (fo == null) {
                continue;
            }
            URL u = URLMapper.findURL(sg.getRootFolder(), URLMapper.INTERNAL);
            BinaryForSourceQuery.Result r = BinaryForSourceQuery.findBinaryRoots(u);
            for (URL u2 : r.getRoots()) {
                String modName = SourceUtils.getModuleName(u2, true);
                if (modName != null) {
                    result.add(modName);
                }
            }
        }
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ShellProjectUtils.java


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