本文整理汇总了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;
}
示例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()]);
}
示例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;
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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"));
}
示例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));
}
示例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);
}
示例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 ();
}
示例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;
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}