本文整理汇总了Java中org.openide.filesystems.FileObject.getURL方法的典型用法代码示例。如果您正苦于以下问题:Java FileObject.getURL方法的具体用法?Java FileObject.getURL怎么用?Java FileObject.getURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.filesystems.FileObject
的用法示例。
在下文中一共展示了FileObject.getURL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: iconFromResourceName
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private static NbImageIcon iconFromResourceName(String resName, FileObject srcFile) {
ClassPath cp = ClassPath.getClassPath(srcFile, ClassPath.SOURCE);
FileObject fo = cp.findResource(resName);
if (fo == null) {
cp = ClassPath.getClassPath(srcFile, ClassPath.EXECUTE);
fo = cp.findResource(resName);
}
if (fo != null) {
try {
try {
Image image = ImageIO.read(fo.getURL());
if (image != null) { // issue 157546
return new NbImageIcon(TYPE_CLASSPATH, resName, new ImageIcon(image));
}
} catch (IllegalArgumentException iaex) { // Issue 178906
Logger.getLogger(IconEditor.class.getName()).log(Level.INFO, null, iaex);
return new NbImageIcon(TYPE_CLASSPATH, resName, new ImageIcon(fo.getURL()));
}
} catch (IOException ex) { // should not happen
Logger.getLogger(IconEditor.class.getName()).log(Level.WARNING, null, ex);
}
}
return null;
}
示例2: parse
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
* Converts to InputSource and pass it.
*/
protected TreeDocumentRoot parse(FileObject fo) throws IOException, TreeException{
try {
URL url = fo.getURL();
InputSource in = new InputSource(url.toExternalForm()); //!!! we could try ti get encoding from MIME content type
in.setByteStream(fo.getInputStream());
return parse(in);
} catch (IOException ex) {
ErrorManager emgr = ErrorManager.getDefault();
emgr.annotate(ex, Util.THIS.getString("MSG_can_not_create_URL"));
emgr.notify(ex);
}
return null;
}
示例3: getUrl
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
protected URL getUrl(JTextComponent comp) {
FileObject f = null;
if (comp instanceof Lookup.Provider) {
f = ((Lookup.Provider) comp).getLookup().lookup(FileObject.class);
}
if (f == null) {
Container container = comp.getParent();
while (container != null) {
if (container instanceof Lookup.Provider) {
f = ((Lookup.Provider) container).getLookup().lookup(FileObject.class);
if (f != null) {
break;
}
}
container = container.getParent();
}
}
if (f != null) {
try {
return f.getURL();
} catch (FileStateInvalidException e) {
LOG.log(Level.WARNING, "Can't get URL for " + f, e); //NOI18N
}
}
return null;
}
示例4: noJavadocFound
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private String noJavadocFound() {
if (handle != null) {
final List<ClassPath> cps = new ArrayList<>(2);
ClassPath cp = cpInfo.getClassPath(ClasspathInfo.PathKind.BOOT);
if (cp != null) {
cps.add(cp);
}
cp = cpInfo.getClassPath(ClasspathInfo.PathKind.COMPILE);
if (cp != null) {
cps.add(cp);
}
cp = ClassPathSupport.createProxyClassPath(cps.toArray(new ClassPath[cps.size()]));
String toSearch = SourceUtils.getJVMSignature(handle)[0].replace('.', '/');
if (handle.getKind() != ElementKind.PACKAGE) {
toSearch += ".class"; //NOI18N
}
final FileObject resource = cp.findResource(toSearch);
if (resource != null) {
final FileObject root = cp.findOwnerRoot(resource);
try {
final URL rootURL = root.getURL();
if (JavadocForBinaryQuery.findJavadoc(rootURL).getRoots().length == 0) {
FileObject userRoot = FileUtil.getArchiveFile(root);
if (userRoot == null) {
userRoot = root;
}
return NbBundle.getMessage(
ElementJavadoc.class,
"javadoc_content_not_found_attach",
rootURL.toExternalForm(),
FileUtil.getFileDisplayName(userRoot));
}
} catch (FileStateInvalidException ex) {
Exceptions.printStackTrace(ex);
}
}
}
return NbBundle.getMessage(ElementJavadoc.class, "javadoc_content_not_found"); //NOI18N
}
示例5: IconFileItem
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
IconFileItem(FileObject file) {
this.file = file;
try {
try {
Image image = (file.getSize() < SIZE_LIMIT) ? ImageIO.read(file.getURL()) : null;
icon = (image != null) ? new ImageIcon(image) : null;
} catch (IllegalArgumentException iaex) { // Issue 178906
Logger.getLogger(CustomIconEditor.class.getName()).log(Level.INFO, null, iaex);
icon = new ImageIcon(file.getURL());
}
} catch (IOException ex) {
Logger.getLogger(CustomIconEditor.class.getName()).log(Level.WARNING, null, ex);
}
}
示例6: getFileObject
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public FileObject getFileObject() {
//source does not exist
FileObject file = SourceUtils.getFile(el, cpInfo);
//tzezula: Very strange and probably useless
if (file == null && source != null) {
FileObject fo = URLMapper.findFileObject(source);
if (fo == null) {
log.log(Level.INFO, "There is no fileobject for source: " +source + ". Was this file removed?");
return file;
}
file = fo;
if (fo.getNameExt().endsWith(FileObjects.SIG)) {
//NOI18N
//conversion sig -> class
String pkgName = FileObjects.convertPackage2Folder(qualName);
StringTokenizer tk = new StringTokenizer(pkgName, "/"); //NOI18N
for (int i = 0; fo != null && i <= tk.countTokens(); i++) {
fo = fo.getParent();
}
if (fo != null) {
try {
URL url = fo.getURL();
URL sourceRoot = null;//XXX: Index.getSourceRootForClassFolder(url);
if (sourceRoot != null) {
FileObject root = URLMapper.findFileObject(sourceRoot);
String resourceName = FileUtil.getRelativePath(fo, URLMapper.findFileObject(source));
file = root.getFileObject(resourceName.replace('.'+FileObjects.SIG, '.'+FileObjects.CLASS)); //NOI18N
} else {
Logger.getLogger(TreePathHandle.class.getName()).fine("Index.getSourceRootForClassFolder(url) returned null for url=" + url); //NOI18N
}
} catch (FileStateInvalidException ex) {
Exceptions.printStackTrace(ex);
}
}
}
}
return file;
}
示例7: register
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static void register (FileObject binRoot, FileObject sourceRoot) throws IOException {
URL url = binRoot.getURL();
map.put (url,sourceRoot);
Result r = results.get (url);
if (r != null) {
r.update (sourceRoot);
}
}
示例8: unregister
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static void unregister (FileObject binRoot) throws IOException {
URL url = binRoot.getURL();
map.remove(url);
Result r = results.get (url);
if (r != null) {
r.update (null);
}
}
示例9: copyAppletHTML
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public static URL copyAppletHTML(Project project, PropertyEvaluator props, FileObject profiledClassFile, String value) {
try {
String buildDirProp = props.getProperty("build.dir"); //NOI18N
FileObject buildFolder = getOrCreateBuildFolder(project, buildDirProp);
FileObject htmlFile;
htmlFile = profiledClassFile.getParent().getFileObject(profiledClassFile.getName(), "html"); //NOI18N
if (htmlFile == null) {
htmlFile = profiledClassFile.getParent().getFileObject(profiledClassFile.getName(), "HTML"); //NOI18N
}
if (htmlFile == null) {
return null;
}
FileObject existingFile = buildFolder.getFileObject(htmlFile.getName(), htmlFile.getExt());
if (existingFile != null) {
existingFile.delete();
}
htmlFile.copy(buildFolder, profiledClassFile.getName(), value).getURL();
return htmlFile.getURL();
} catch (IOException e) {
ErrorManager.getDefault()
.annotate(e, Bundle.ProjectUtilities_FailedCopyAppletFileMsg(e.getMessage()));
ErrorManager.getDefault().notify(ErrorManager.ERROR, e);
return null;
}
}
示例10: findUnitTests
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public URL[] findUnitTests(FileObject source) {
URL[][] data = findSourcesAndTests();
URL sourceURL;
try {
sourceURL = source.getURL();
} catch (FileStateInvalidException e) {
return null;
}
if (Arrays.asList(data[0]).contains(sourceURL)) {
return data[1];
} else {
return null;
}
}
示例11: findSources
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
public URL[] findSources(FileObject unitTest) {
URL[][] data = findSourcesAndTests();
URL testURL;
try {
testURL = unitTest.getURL();
} catch (FileStateInvalidException e) {
return null;
}
if (Arrays.asList(data[1]).contains(testURL)) {
return data[0];
} else {
return null;
}
}
示例12: checkFileObjectURLMapping
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private void checkFileObjectURLMapping(FileObject fo, URL url, URLMapper mapper) throws Exception {
log ("Testing " + fo);
log (" -> " + url);
assertNotNull("The file tested is null.", fo);
assertNotNull("Mapper does not produce a URL for file " + fo, url);
FileObject newFo[] = mapper.getFileObjects(url);
assertNotNull("Mapper does not produce file for URL " + url, newFo);
if (newFo.length != 1) {
fail("Mapper returned array of size " + newFo.length + " for URL " + url);
}
assertEquals("Mapping does not produce the original object: " + fo + " != " + newFo, fo, newFo[0]);
// compare the streams
URL u2 = fo.getURL();
compareStream(url.openStream(), u2.openStream());
}
示例13: resolveIconPath
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/**
* translates resource path defined in {@link java.beans.BeanInfo}'s subclass
* that complies with {@link Class#getResource(java.lang.String) Class.getResource} format
* to format complying with {@link ClassPath#getResourceName(org.openide.filesystems.FileObject) ClassPath.getResourceName}
* @param resourcePath absolute path or path relative to package of BeanInfo's subclass
* @param beanInfo BeanInfo's subclass
* @return path as URL
* @throws FileStateInvalidException invalid FileObject
* @throws FileNotFoundException resource cannot be found
*/
private static URL resolveIconPath(String resourcePath, FileObject beanInfo)
throws FileStateInvalidException, FileNotFoundException {
ClassPath cp = ClassPath.getClassPath(beanInfo, ClassPath.SOURCE);
String path = resourcePath.charAt(0) != '/'
? '/' + cp.getResourceName(beanInfo.getParent()) + '/' + resourcePath
: resourcePath;
FileObject res = cp.findResource(path);
if (res != null && res.canRead() && res.isData()) {
return res.getURL();
} else {
throw new FileNotFoundException(path);
}
}
示例14: resolveEntity
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
/** Tries to find the entity on system file system.
*/
public InputSource resolveEntity(String publicID, String systemID) throws IOException, SAXException {
if (publicID == null) {
return null;
}
String id = convertPublicId (publicID);
StringBuffer sb = new StringBuffer (200);
sb.append (ENTITY_PREFIX);
sb.append (id);
FileObject fo = FileUtil.getConfigFile (sb.toString ());
if (fo != null) {
// fill in InputSource instance
InputSource in = new InputSource (fo.getInputStream ());
try {
Object myPublicID = fo.getAttribute("hint.originalPublicID"); //NOI18N
if (myPublicID instanceof String) {
in.setPublicId((String)myPublicID);
}
URL url = fo.getURL();
in.setSystemId(url.toString()); // we get nasty nbfs: instead nbres: but it is enough
} catch (IOException ex) {
// do no care just no system id
}
return in;
} else {
return null;
}
}
示例15: updateURL
import org.openide.filesystems.FileObject; //导入方法依赖的package包/类
private synchronized void updateURL(FileObject file) {
try {
fileURL = file.getURL();
} catch (FileStateInvalidException ex) {
fileURL = null;
}
}