本文整理汇总了Java中org.openide.filesystems.FileObject.toURL方法的典型用法代码示例。如果您正苦于以下问题:Java FileObject.toURL方法的具体用法?Java FileObject.toURL怎么用?Java FileObject.toURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.filesystems.FileObject
的用法示例。
在下文中一共展示了FileObject.toURL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDeleteListener
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
public synchronized boolean addDeleteListener(DeleteListener l) {
boolean added = super.addDeleteListener(l);
if (added && projectDeleteListener == null) {
Project p = getProject(getURL());
if (p != null) {
FileObject projDir = p.getProjectDirectory();
projectDeleteListener = new ProjectDeleteListener(projDir.toURL(), this);
projDir.addFileChangeListener(projectDeleteListener);
} else {
super.removeDeleteListener(l);
added = false;
}
}
return added;
}
示例2: getClassPathEntry
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@org.netbeans.api.annotations.common.SuppressWarnings(
value="DMI_BLOCKING_METHODS_ON_URL",
justification="URLs have never host part")
private static ClassPath.Entry getClassPathEntry (final FileObject root) {
if (root != null) {
Set<String> ids = PathRegistry.getDefault().getSourceIdsFor(root.toURL());
if (ids != null) {
for (String id : ids) {
ClassPath cp = ClassPath.getClassPath(root, id);
if (cp != null) {
URL rootURL = root.toURL();
for (ClassPath.Entry e : cp.entries()) {
if (rootURL.equals(e.getURL())) {
return e;
}
}
}
}
}
}
return null;
}
示例3: findResource
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
protected URL findResource(String name) {
// In design time some resources added/changed by the user might not be propagated
// to execution classpath yet (until the project is rebuilt), so not found by
// custom components. That's why we prefer to look for them on sources classpath
// first (bug 69377). An exception is use of @NbBundle.Messages annotations which
// fills the properties file only in built results. If the same file is also
// present in sources then it is incomplete and we should not use it (bug 238094).
if ((!name.equals("Bundle.properties") && !name.endsWith("/Bundle.properties")) // NOI18N
|| !isProjectWithNbBundle()) {
FileObject fo = sources.findResource(name);
if (fo != null) {
return fo.toURL();
}
}
return projectClassLoaderDelegate.getResource(name);
}
示例4: collectClasspathRoots
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static void collectClasspathRoots(FileObject file, Collection<String> pathIds, boolean binaryPaths, Collection<FileObject> roots) {
for(String id : pathIds) {
Collection<FileObject> classpathRoots = getClasspathRoots(file, id);
if (binaryPaths) {
// Filter out roots that do not have source files available
for(FileObject binRoot : classpathRoots) {
final URL binRootUrl = binRoot.toURL();
URL[] srcRoots = PathRegistry.getDefault().sourceForBinaryQuery(binRootUrl, null, false);
if (srcRoots != null) {
LOG.log(Level.FINE, "Translating {0} -> {1}", new Object [] { binRootUrl, srcRoots }); //NOI18N
for(URL srcRootUrl : srcRoots) {
FileObject srcRoot = URLCache.getInstance().findFileObject(srcRootUrl, false);
if (srcRoot != null) {
roots.add(srcRoot);
}
}
} else {
LOG.log(Level.FINE, "No sources for {0}, adding bin root", binRootUrl); //NOI18N
roots.add(binRoot);
}
}
} else {
roots.addAll(classpathRoots);
}
}
}
示例5: APTUtils
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private APTUtils(@NonNull final FileObject root) {
this.root = root;
bootPath = ClassPath.getClassPath(root, ClassPath.BOOT);
compilePath = ClassPath.getClassPath(root, ClassPath.COMPILE);
processorPath = new AtomicReference<>(ClassPath.getClassPath(root, JavaClassPathConstants.PROCESSOR_PATH));
processorModulePath = new AtomicReference<>(ClassPath.getClassPath(root, JavaClassPathConstants.MODULE_PROCESSOR_PATH));
aptOptions = AnnotationProcessingQuery.getAnnotationProcessingOptions(root);
sourceLevel = SourceLevelQuery.getSourceLevel2(root);
compilerOptions = CompilerOptionsQuery.getOptions(root);
this.slidingRefresh = RP.create(() -> {
IndexingManager.getDefault().refreshIndex(
root.toURL(),
Collections.<URL>emptyList(),
false);
});
usedRoots = new UsedRoots(root.toURL());
}
示例6: getSystemId
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
* Get InputSource system ID. Use ordered logic:
* <ul>
* <li>use client's <code>setSystemId()</code>, or
* <li>try to derive it from <code>Document</code>
* <p>e.g. look at <code>Document.StreamDescriptionProperty</code> for
* {@link DataObject} and use URL of its primary file.
* </ul>
* @return entity system Id or <code>null</code>
*/
public String getSystemId() {
String system = super.getSystemId();
// XML module specifics property, promote into this API
// String system = (String) doc.getProperty(TextEditorSupport.PROP_DOCUMENT_URL);
if (system == null) {
final FileObject fo = EditorDocumentUtils.getFileObject(doc);
if (fo != null) {
URL url = fo.toURL();
system = url.toExternalForm();
} else {
LOG.info("XML:DocumentInputSource:No FileObject in stream description."); //NOI18N
}
}
return system;
}
示例7: getCrc32
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/** Find (maybe cached) CRC for a file. Will open its own input stream. */
private static String getCrc32(FileObject fo) throws IOException {
URL u = fo.toURL();
fo.refresh();
long footprint = fo.lastModified().getTime() ^ fo.getSize();
String crc = findCachedCrc32(u, footprint);
if (crc == null) {
InputStream is = fo.getInputStream();
try {
crc = computeCrc32(new BufferedInputStream(is));
cacheCrc32(crc, u, footprint);
} finally {
is.close();
}
}
return crc;
}
示例8: createClassPath
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static ClassPath createClassPath(FileObject[] froots) {
List<PathResourceImplementation> pris = new ArrayList<PathResourceImplementation> ();
for (FileObject fo : froots) {
if (fo != null && fo.canRead()) {
try {
URL url = fo.toURL();
pris.add(ClassPathSupport.createResource(url));
} catch (IllegalArgumentException iaex) {
// Can be thrown from ClassPathSupport.createResource()
// Ignore - bad source root
//logger.log(Level.INFO, "Invalid source root = "+fo, iaex);
logger.warning(iaex.getLocalizedMessage());
}
}
}
return ClassPathSupport.createClassPath(pris);
}
示例9: getNormalizedURL
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private URL getNormalizedURL (URL url) {
//URL is already nornalized, return it
final Boolean isNormalized = isNormalizedURL(url);
if (isNormalized == null) {
return null;
}
if (isNormalized == Boolean.TRUE) {
return url;
}
//Todo: Should listen on the LibrariesManager and cleanup cache
// in this case the search can use the cache onle and can be faster
// from O(n) to O(ln(n))
URI uri = null;
try {
uri = url.toURI();
} catch (URISyntaxException e) {
Exceptions.printStackTrace(e);
}
URL normalizedURL = uri == null ? null : normalizedURLCache.get(uri);
if (normalizedURL == null) {
final FileObject fo = URLMapper.findFileObject(url);
if (fo != null) {
normalizedURL = fo.toURL();
if (uri != null) {
this.normalizedURLCache.put (uri, normalizedURL);
}
}
}
return normalizedURL;
}
示例10: setUp
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Before
@Override
public void setUp() throws IOException {
clearWorkDir();
final File wd = getWorkDir();
final FileObject src1 = FileUtil.createFolder(FileUtil.normalizeFile(
new File(wd,"src"))); //NOI18N
final FileObject src2 = FileUtil.createFolder(FileUtil.normalizeFile(
new File(wd,"src2"))); //NOI18N
nonSrcUrl = BaseUtilities.toURI(wd).toURL();
srcUrl1 = src1.toURL();
srcUrl2 = src2.toURL();
impl1 = new ActionImpl();
impl2 = new ActionImpl();
impl3 = new ActionImpl();
MockLookup.setInstances(
new ProviderImpl(srcUrl1, impl1),
new ProviderImpl(srcUrl2, impl2),
new ProviderImpl(srcUrl1, impl3));
//Enable all
impl1.setEnabled(true);
impl1.setUpdateClasses(true);
impl1.setUpdateResources(true);
impl2.setEnabled(true);
impl2.setUpdateClasses(true);
impl2.setUpdateResources(true);
impl3.setEnabled(true);
impl3.setUpdateClasses(true);
impl3.setUpdateResources(true);
}
示例11: unregister
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static void unregister (FileObject binRoot) throws IOException {
URL url = binRoot.toURL();
map.remove(url);
Result r = results.get (url);
if (r != null) {
r.update (null);
}
}
示例12: getSourceFile
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public URL getSourceFile(String name, int hash, SourceContent content) {
String path = Integer.toHexString(hash) + '/' + name;
FileObject fo = fs.findResource(path);
if (fo == null) {
fo = fs.createFile(path, content);
}
return fo.toURL();
}
示例13: addToSourcePath
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void addToSourcePath(FileObject sourceRoot, boolean clearURLCaches) {
URL newURL = sourceRoot.toURL();
synchronized (SourcePathProviderImpl.this) {
if (originalSourcePath == null) {
return ;
}
List<URL> sourcePaths = getURLRoots(originalSourcePath);
sourcePaths.add(newURL);
originalSourcePath =
SourcePathProviderImpl.createClassPath(
sourcePaths.toArray(new URL[0]));
sourcePaths = getURLRoots(smartSteppingSourcePath);
sourcePaths.add(newURL);
smartSteppingSourcePath =
SourcePathProviderImpl.createClassPath(
sourcePaths.toArray(new URL[0]));
}
if (clearURLCaches) {
synchronized (urlCache) {
urlCache.clear();
}
synchronized (urlCacheGlobal) {
urlCacheGlobal.clear();
}
}
pcs.firePropertyChange (PROP_SOURCE_ROOTS, null, null);
}
示例14: getURL
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@Override
public URL getURL() {
if (url == null) {
try {
FileObject f = getFileObject();
if (f != null) {
url = f.toURL();
if (LOG.isLoggable(Level.FINEST)) {
LOG.log(
Level.FINEST,
"URL from existing FileObject: {0} = {1}", //NOI18N
new Object[] {
FileUtil.getFileDisplayName(f),
url
});
}
} else {
url = Util.resolveUrl(root.toURL(), relativePath, false);
if (LOG.isLoggable(Level.FINEST)) {
LOG.log(
Level.FINEST,
"URL from non existing FileObject root: {0} ({1}), relative path: {2} = {3}", //NOI18N
new Object[] {
FileUtil.getFileDisplayName(root),
root.toURL(),
relativePath,
url
});
}
}
} catch (MalformedURLException ex) {
url = ex;
}
}
return url instanceof URL ? (URL) url : null;
}
示例15: findImpl
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
@NonNull
private Optional<Pair<String,ClassPath>> findImpl(@NonNull final FileObject artifact) {
final Map<String,Pair<ClassPath,CPImpl>> data = getCache();
final URL artifactURL = artifact.toURL();
for (Map.Entry<String,Pair<ClassPath,CPImpl>> e : data.entrySet()) {
final ClassPath cp = e.getValue().first();
for (ClassPath.Entry cpe : cp.entries()) {
if (Utilities.isParentOf(cpe.getURL(), artifactURL)) {
return Optional.of(Pair.of(e.getKey(), cp));
}
}
}
return Optional.empty();
}