Index: api/doc/changes/apichanges.xml =================================================================== RCS file: /cvs/openide/api/doc/changes/apichanges.xml,v --- api/doc/changes/apichanges.xml 1.191 +++ api/doc/changes/apichanges.xml @@ -119,0 +119,17 @@ + + There should exist just one FileObject for one resource (java.io.File or URL). + + + + + +
    +
  • Added method FileUtil.toFileObject as replacement for current method FileUtil.fromFile which was deprecated.
  • +
  • Added method URLMapper.findFileObject as replacement for current method URLMapper.findFileObjects which was deprecated .
  • +
+
+ + + + + Index: src/org/openide/filesystems/FileUtil.java =================================================================== RCS file: /cvs/openide/src/org/openide/filesystems/FileUtil.java,v --- src/org/openide/filesystems/FileUtil.java 1.79 +++ src/org/openide/filesystems/FileUtil.java @@ -276,0 +276,11 @@ + * If not possible then null is returned. + * @param file File whose coresponding FileObjects will be looked for + * @return corresponding FileObject or null + * @since X.XX + */ + public static FileObject toFileObject (File file) { + FileObject[] fileObjects = fromFile (file); + return (fileObjects != null && fileObjects.length > 0) ? fileObjects[0] : null; + } + /** Finds appropriate FileObjects to java.io.File if possible. @@ -282,0 +293,1 @@ + * @deprecated Use method {@link #toFileObject toFileObject} @@ -858,1 +870,1 @@ - return findFileObject(getArchiveRoot(archiveURL)); --- + return URLMapper.findFileObject(getArchiveRoot(archiveURL)); @@ -967,1 +979,1 @@ - FileObject fo = findFileObject(url); --- + FileObject fo = URLMapper.findFileObject(url); Index: src/org/openide/filesystems/URLMapper.java =================================================================== RCS file: /cvs/openide/src/org/openide/filesystems/URLMapper.java,v --- src/org/openide/filesystems/URLMapper.java 1.27 +++ src/org/openide/filesystems/URLMapper.java @@ -114,1 +114,3 @@ - * @since 2.22*/ --- + * @since 2.22 + * @deprecated use method {@link #findFileObject findFileObject} + */ @@ -134,1 +136,26 @@ - /** Get an array of FileObjects for this url --- + /** Find an appropiate instance of FileObject that addresses this url + * + * @param url url to be converted to file object + * @return file object corresponding to url or null if no one was found + * @since X.XX + */ + public static FileObject findFileObject (URL url) { + FileObject fos[] = URLMapper.findFileObjects(url); + if (fos.length == 0) { + return null; + } + // prefer file object from master filesystem + for (int i=0; i There isn't necessary to return array here. + * The only one reason is just backward compatibility.

@@ -136,1 +163,1 @@ - * @return a suitable arry of FileObjects, or null --- + * @return an array of FileObjects with size no greater than one, or null