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


Java URLMapper.findFileObject方法代码示例

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


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

示例1: preferFileName

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
private String preferFileName (String systemId) {
    String name = systemId;

    try {
        URL url = new URL (systemId);
        FileObject fo = URLMapper.findFileObject(url);
        if (fo != null) {
            name = TransformUtil.getURLName (fo);
        }
    } catch (Exception exc) {
        // ignore it -> use systemId

        //if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug (exc);
    }

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

示例2: getRoots

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
public URL[] getRoots() {
    FileObject fo = URLMapper.findFileObject(sourceRoot);
    if (fo == null) {
        return new URL[0];
    }
    ClassPath exec = ClassPath.getClassPath(fo, ClassPath.EXECUTE);
    if (exec == null) {
        return new URL[0];
    }           
    Set<URL> result = new HashSet<URL>();
    for (ClassPath.Entry e : exec.entries()) {
        final URL eurl = e.getURL();
        FileObject[] roots = SourceForBinaryQuery.findSourceRoots(eurl).getRoots();
        for (FileObject root : roots) {
                if (sourceRoot.equals (root.toURL())) {
                    result.add (eurl);
                }
        }
    }
    return result.toArray(new URL[result.size()]);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:BinaryForSourceQuery.java

示例3: getFileObjects

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
private static List/*<FileObject>*/ getFileObjects(URL[] urls, boolean quiet) {
    List result = new ArrayList();
    for (int i = 0; i < urls.length; i++) {
        FileObject sourceRoot = URLMapper.findFileObject(urls[i]);
        if (sourceRoot != null) {
            result.add(sourceRoot);
        } else if (! quiet) {
            ErrorManager.getDefault().notify(
                    ErrorManager.INFORMATIONAL,
                    new IllegalStateException("No FileObject found for the following URL: " + urls[i])); //NOI18N
        }
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:SourceGroupSupport.java

示例4: createLocation

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
/**
 * creates a new persistence location using the maven resource folder
 * -> /src/main/resources/META-INF
 * @return the newly created FileObject the location (eg. parent folder) 
 * of the persistence.xml file
 * @throws java.io.IOException if location can not be created
 */
@Override
public FileObject createLocation() throws IOException {
    FileObject retVal = null;
    URI[] resources = mproject!=null ? mproject.getResources(false) : null;
    if(resources!=null && resources.length>0) {
        try {
            FileObject res = URLMapper.findFileObject(resources[0].toURL());
            retVal = res.getFileObject(REL_LOCATION);
            if(retVal == null){
                retVal = res.createFolder(REL_LOCATION);
            }
        } catch (Exception ex) {

        }
    } 
    if(retVal == null) {
        File defaultLocation = FileUtilities.resolveFilePath(
                projectDir, DEF_LOCATION);

        if (!defaultLocation.exists()) {
            retVal = FileUtil.createFolder(
                    project.getProjectDirectory(), DEF_LOCATION);
        }

        retVal = FileUtil.toFileObject(defaultLocation);

        location = retVal;
    }

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

示例5: findLookupFor

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
private static Lookup findLookupFor(NavigationHistory.Waypoint wpt) {
    // try component first
    JTextComponent component = wpt.getComponent();
    if (component != null) {
        for (java.awt.Component c = component; c != null; c = c.getParent()) {
            if (c instanceof Lookup.Provider) {
                Lookup lookup = ((Lookup.Provider)c).getLookup ();
                if (lookup != null) {
                    return lookup;
                }
            }
        }
    }

    // now try DataObject
    URL url = wpt.getUrl();
    FileObject f = url == null ? null : URLMapper.findFileObject(url);
    
    if (f != null) {
        try {
            return DataObject.find(f).getLookup();
        } catch (DataObjectNotFoundException e) {
            LOG.log(Level.WARNING, "Can't get DataObject for " + f, e); //NOI18N
        }
    }
    
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:NavigationHistoryBackAction.java

示例6: loadFileList

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
private <T> List<T> loadFileList(String basekey, Class<T> type) throws BackingStoreException {
    Preferences pref = NbPreferences.forModule(JavaScopeBuilder.class).node(PREF_SCOPE).node(basekey);
    List<T> toRet = new LinkedList<T>();
    for (String key : pref.keys()) {
        final String url = pref.get(key, null);
        if (url != null && !url.isEmpty()) {
            try {
                final FileObject f = URLMapper.findFileObject(new URL(url));
                if (f != null && f.isValid()) {
                    if (type.isAssignableFrom(FileObject.class)) {
                        toRet.add((T) f);
                    } else {
                        toRet.add((T) new NonRecursiveFolder() {
                            @Override
                            public FileObject getFolder() {
                                return f;
                            }
                        });
                    }
                }
            } catch (MalformedURLException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    }
    return toRet;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:CustomScopeProvider.java

示例7: findOpposite

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
static @CheckForNull FileObject findOpposite(FileObject rule, boolean toTest) {
    ClassPath cp = ClassPath.getClassPath(rule, ClassPath.SOURCE);
    String resourceName = cp != null ? cp.getResourceName(rule) : null;

    if (resourceName == null) {
        Logger.getLogger(TestLocatorImpl.class.getName()).log(Level.FINE, "cp==null or rule file cannot be found on its own source cp");
        return null;
    }

    String testFileName = resourceName.substring(0, resourceName.lastIndexOf('.')) + (toTest ? ".test" : ".hint");

    FileObject testFile = cp.findResource(testFileName);

    if (testFile == null) {
        URL[] sr;

        if (toTest) {
            sr = UnitTestForSourceQuery.findUnitTests(cp.findOwnerRoot(rule));
        } else {
            sr = UnitTestForSourceQuery.findSources(cp.findOwnerRoot(rule));
        }
        
        for (URL testRoot : sr) {
            FileObject testRootFO = URLMapper.findFileObject(testRoot);

            if (testRootFO != null) {
                testFile = testRootFO.getFileObject(testFileName);

                if (testFile != null) {
                    break;
                }
            }
        }
    }

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

示例8: getCommandLineMavenVersion

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
public static @CheckForNull String getCommandLineMavenVersion(File mavenHome) {
    File[] jars = new File(mavenHome, "lib").listFiles(new FilenameFilter() { // NOI18N
        public @Override boolean accept(File dir, String name) {
            return name.endsWith(".jar"); // NOI18N
        }
    });
    if (jars == null) {
        return null;
    }
    for (File jar : jars) {
        try {
            // Prefer to use this rather than raw ZipFile since URLMapper since ArchiveURLMapper will cache JARs:
            FileObject entry = URLMapper.findFileObject(new URL(FileUtil.urlForArchiveOrDir(jar), "META-INF/maven/org.apache.maven/maven-core/pom.properties")); // NOI18N
            if (entry != null) {
                InputStream is = entry.getInputStream();
                try {
                    Properties properties = new Properties();
                    properties.load(is);
                    return properties.getProperty("version"); // NOI18N
                } finally {
                    is.close();
                }
            }
        } catch (IOException x) {
            // ignore for now
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:MavenSettings.java

示例9: getFileObject

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
public FileObject getFileObject() {
    try {
        return URLMapper.findFileObject(getController().getCompilationUnit().getSourceFile().toUri().toURL());
    } catch (MalformedURLException ex) {
        Exceptions.printStackTrace(ex);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:JPACodeCompletionProvider.java

示例10: findProject

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
public static Project findProject(URI projectURI) {
    if (projectURI != null) {
        try {
            FileObject prjFO = URLMapper.findFileObject(projectURI.toURL());
            if (prjFO != null && prjFO.isFolder()) {
                return ProjectManager.getDefault().findProject(prjFO);
            }
        } catch (IOException ex) {
            // Cannot load project -> return null
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:BookmarkUtils.java

示例11: updateErrorsInRoot

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
private static synchronized void updateErrorsInRoot(
        final Callback callback,
        final FileObject root,
        final AtomicBoolean cancelled) {
    Set<FileObject> filesWithErrors = getFilesWithAttachedErrors(root);
    Set<FileObject> fixedFiles = new HashSet<FileObject>(filesWithErrors);
    Set<FileObject> nueFilesWithErrors = new HashSet<FileObject>();

    try {
        for (URL u : TaskCache.getDefault().getAllFilesWithRecord(root.toURL())) {
            if (cancelled.get()) {
                return;
            }
            FileObject file = URLMapper.findFileObject(u);

            if (file != null) {
                List<Task> result = TaskCache.getDefault().getErrors(file);

                LOG.log(Level.FINE, "Setting {1} for {0}\n", new Object[] {file, result});

                callback.setTasks(file, result);

                if (!fixedFiles.remove(file)) {
                    nueFilesWithErrors.add(file);
                }
            }
        }
    } catch (IOException e) {
        Exceptions.printStackTrace(e);
    }
    
    for (FileObject f : fixedFiles) {
        LOG.log(Level.FINE, "Clearing errors for {0}", f);
        callback.setTasks(f, Collections.<Task>emptyList());
    }
    
    filesWithErrors.addAll(nueFilesWithErrors);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:TaskProvider.java

示例12: createGroupParser

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
private GroupParser createGroupParser (String path, String name) {
    URL url;
    url = GroupParserTest.class.getResource(path);
    assertNotNull("url not found.",url);
    
    FileObject parentFolder = URLMapper.findFileObject(url);
    assertNotNull("Test parent folder not found. ParentFolder is null. for " + url, parentFolder);
    
    GroupParser groupParser = new GroupParser(name);
    groupParser.setInLocalFolder(true);
    groupParser.setLocalParentFolder(parentFolder);
    
    return groupParser;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:GroupParserTest.java

示例13: suite

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
public static TestSuite suite(Class<?> clazz, String filePattern) {
    NbTestSuite result = new NbTestSuite();
    Pattern patt = Pattern.compile(filePattern);

    for (String test : listTests(clazz)) {
        if (!patt.matcher(test).matches()) {
            continue;
        }
        
        //TODO:
        URL testURL = clazz.getClassLoader().getResource(test);
        
        assertNotNull(testURL);

        FileObject testFO = URLMapper.findFileObject(testURL);

        assertNotNull(testFO);

        String hint = test.substring(0, test.length() - ".test".length()) + ".hint";
        URL hintURL = clazz.getClassLoader().getResource(hint);

        assertNotNull(hintURL);
        
        FileObject hintFO = URLMapper.findFileObject(hintURL);

        assertNotNull(hintFO);

        try {
            for (TestCase tc : TestParser.parse(testFO.asText("UTF-8"))) {
                result.addTest(new DeclarativeHintsTestBase(hintFO, testFO, tc));
            }
        } catch (IOException ex) {
            throw new IllegalStateException(ex);
        }
    }

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

示例14: isWithin

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
private FileObject isWithin(URI[] res, FileObject file) throws MalformedURLException {
    for (URI ur : res) {
        FileObject fo = URLMapper.findFileObject(ur.toURL());
        if (fo != null && (fo.equals(file) || FileUtil.isParentOf(fo, file))) {
            return fo;
        } 
    }
    return null;
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:MavenFileEncodingQueryImpl.java

示例15: findBreakableLine

import org.openide.filesystems.URLMapper; //导入方法依赖的package包/类
private int findBreakableLine(String url, final int lineNumber) {
    FileObject fileObj = null;
    try {
        fileObj = URLMapper.findFileObject(new URL(url));
    } catch (MalformedURLException e) {
    }
    if (fileObj == null) return lineNumber;
    JavaSource js = JavaSource.forFileObject(fileObj);
    if (js == null) return lineNumber;
    final int[] result = new int[] {lineNumber};
    try {
        js.runUserActionTask(new CancellableTask<CompilationController>() {
            @Override
            public void cancel() {
            }
            @Override
            public void run(CompilationController ci) throws Exception {
                if (ci.toPhase(Phase.RESOLVED).compareTo(Phase.RESOLVED) < 0) {
                    logger.warning(
                            "Unable to resolve "+ci.getFileObject()+" to phase "+Phase.RESOLVED+", current phase = "+ci.getPhase()+
                            "\nDiagnostics = "+ci.getDiagnostics()+
                            "\nFree memory = "+Runtime.getRuntime().freeMemory());
                    return;
                }
                SourcePositions positions = ci.getTrees().getSourcePositions();
                CompilationUnitTree compUnit = ci.getCompilationUnit();
                TreeUtilities treeUtils = ci.getTreeUtilities();
                Document ciDoc = ci.getDocument();
                if (!(ciDoc instanceof LineDocument)) {
                    return ;
                }
                LineDocument doc = (LineDocument) ciDoc;
                int rowStartOffset = LineDocumentUtils.getLineStartFromIndex(doc, lineNumber -1);

                TreePath path = treeUtils.pathFor(rowStartOffset);
                Tree tree = path.getLeaf();
                Tree.Kind kind = tree.getKind();
                if (kind == Tree.Kind.ERRONEOUS) {
                    return ;
                }
                int startOffs = (int)positions.getStartPosition(compUnit, tree);
                int outerLineNumber = LineDocumentUtils.getLineIndex(doc, startOffs) + 1;
                if (outerLineNumber == lineNumber) return;
                if (kind == Tree.Kind.COMPILATION_UNIT || TreeUtilities.CLASS_TREE_KINDS.contains(kind)) return;
                if (kind == Tree.Kind.BLOCK) {
                    BlockTree blockTree = (BlockTree)tree;
                    Tree previousTree = null;
                    int previousTreeEndOffset = -1;
                    for (StatementTree sTree : blockTree.getStatements()) {
                        int end = (int)positions.getStartPosition(compUnit, sTree);
                        if (end <= rowStartOffset && end > previousTreeEndOffset) {
                            previousTree = sTree;
                            previousTreeEndOffset = end;
                        } else if (end > rowStartOffset) {
                            break;
                        }
                    } // for
                    if (previousTree == null) {
                        tree = path.getParentPath().getLeaf();
                        kind = tree.getKind();
                        if (kind != Tree.Kind.COMPILATION_UNIT && !TreeUtilities.CLASS_TREE_KINDS.contains(kind)) {
                            previousTree = tree;
                        } else {
                            return;
                        }
                    }
                    startOffs = (int)positions.getStartPosition(compUnit, previousTree);
                    outerLineNumber = LineDocumentUtils.getLineIndex(doc, startOffs) + 1;
                } // if
                result[0] = outerLineNumber;
            }
        }, true);
    } catch (IOException ioex) {
        Exceptions.printStackTrace(ioex);
        return lineNumber;
    }
    return result[0];
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:79,代码来源:LineBreakpointImpl.java


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