This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 41506
Collapse All | Expand All

(-)api/doc/changes/apichanges.xml (+17 lines)
Lines 116-121 Link Here
116
  <changes>
116
  <changes>
117
    <change>
117
    <change>
118
    <api name="filesystems"/>
119
    <summary>There should exist just one FileObject for one resource (java.io.File or URL).  </summary>
120
    <version major="4" minor="29"/>
121
    <date day="9" month="4" year="2004"/>
122
    <author login="rmatous"/>
123
    <compatibility addition="yes" modification="yes" deprecation="yes" semantic="compatible"/>
124
    <description>
125
        <ul>
126
            <li>Added method FileUtil.toFileObject as replacement for current method FileUtil.fromFile which was deprecated.</li>
127
            <li>Added method URLMapper.findFileObject as replacement for current method URLMapper.findFileObjects which was deprecated .</li>
128
        </ul>
129
    </description>
130
    <class package="org.openide.filesystems" name="FileUtil"/>
131
    <class package="org.openide.filesystems" name="URLMapper"/>
132
    <issue number="41506"/>
133
    </change>
134
    <change>
118
     <api name="dialogs"/>
135
     <api name="dialogs"/>
119
     <summary>Allow dynamically enable/disable Finish button</summary>
136
     <summary>Allow dynamically enable/disable Finish button</summary>
120
     <version major="4" minor="28"/>
137
     <version major="4" minor="28"/>
(-)src/org/openide/filesystems/FileUtil.java (-25 / +14 lines)
Lines 273-284 Link Here
273
    }
273
    }
274
    /** Finds appropriate FileObjects to java.io.File if possible.
274
    /** Finds appropriate FileObjects to java.io.File if possible.
275
     * If not possible then null is returned.
276
     * @param file File whose coresponding FileObjects will be looked for
277
     * @return corresponding FileObject or null
278
     * @since X.XX
279
     */
280
    public static FileObject toFileObject (File file) {
281
        FileObject[] fileObjects = fromFile (file);
282
        return (fileObjects != null && fileObjects.length > 0) ? fileObjects[0] : null;
283
    }
284
285
    /** Finds appropriate FileObjects to java.io.File if possible.
275
     * If not possible then empty array is returned. More FileObjects may
286
     * If not possible then empty array is returned. More FileObjects may
276
     * correspond to one java.io.File that`s why array is returned.
287
     * correspond to one java.io.File that`s why array is returned.
277
     * @param file File whose coresponding FileObjects will be looked for
288
     * @param file File whose coresponding FileObjects will be looked for
278
     * @return corresponding FileObjects or empty array  if no
289
     * @return corresponding FileObjects or empty array  if no
279
     * corresponding FileObject exists.
290
     * corresponding FileObject exists.
280
     * @since 1.29
291
     * @since 1.29
292
     * @deprecated Use method {@link #toFileObject toFileObject}
281
     */
293
     */
282
    public static FileObject[] fromFile (File file) {
294
    public static FileObject[] fromFile (File file) {
283
        assert file.equals(normalizeFile(file)) : file;
295
        assert file.equals(normalizeFile(file)) : file;
Lines 821-849 Link Here
821
    }
833
    }
822
    /**
834
    /**
823
     * This method is very similar to URLMapper.findFileObjects(URL) with
824
     * difference that it returns just one file object and that it knows
825
     * which file object must be used from available ones.
826
     *
827
     * @param url url to be converted to file object
828
     * @return file object corresponding to url or null if no one was found
829
     * @since XXX
830
     */
831
    public static FileObject findFileObject(URL url) {
832
        FileObject fos[] = URLMapper.findFileObjects(url);
833
        if (fos.length == 0) {
834
            return null;
835
        }
836
        // prefer file object from master filesystem
837
        for (int i=0; i<fos.length; i++) {
838
            if (fos[i].getClass().getName().indexOf("masterfs") != -1) {        //NOI18N
839
                return fos[i];
840
            }
841
        }
842
        return fos[0];
843
    }
844
845
    /**
846
     * Returns a FileObject of the root of an jar/zip archive
835
     * Returns a FileObject of the root of an jar/zip archive
847
     * given be an argument.
836
     * given be an argument.
848
     * @param fo FileObject of the zip/jar archive file
837
     * @param fo FileObject of the zip/jar archive file
Lines 855-861 Link Here
855
        if (archiveURL == null) {
844
        if (archiveURL == null) {
856
            return null;
845
            return null;
857
        }
846
        }
858
        return findFileObject(getArchiveRoot(archiveURL));
847
        return URLMapper.findFileObject(getArchiveRoot(archiveURL));
859
    }
848
    }
860
    /**
849
    /**
Lines 964-970 Link Here
964
     * @since XXX
953
     * @since XXX
965
     */
954
     */
966
    public static boolean isArchiveFile (URL url) {
955
    public static boolean isArchiveFile (URL url) {
967
        FileObject fo = findFileObject(url);
956
        FileObject fo = URLMapper.findFileObject(url);
968
        if (fo!=null) {
957
        if (fo!=null) {
969
            return isArchiveFile(fo);
958
            return isArchiveFile(fo);
970
        }
959
        }
(-)src/org/openide/filesystems/URLMapper.java (-3 / +30 lines)
Lines 111-117 Link Here
111
     * <code> findURL(FileObject fo, int type) </code>.
111
     * <code> findURL(FileObject fo, int type) </code>.
112
     * @param url to wanted FileObjects
112
     * @param url to wanted FileObjects
113
     * @return a suitable arry of FileObjects, or empty array if not successful
113
     * @return a suitable arry of FileObjects, or empty array if not successful
114
     * @since  2.22*/
114
     * @since  2.22
115
     * @deprecated use method {@link #findFileObject findFileObject}
116
     */
115
    public static FileObject[] findFileObjects (URL url) {
117
    public static FileObject[] findFileObjects (URL url) {
116
        /** first basic implementation */
118
        /** first basic implementation */
117
        Set retSet = new HashSet ();
119
        Set retSet = new HashSet ();
Lines 131-139 Link Here
131
        return retVal;
133
        return retVal;
132
    }
134
    }
133
    /** Get an array of FileObjects for this url
135
    /** Find an appropiate instance of FileObject that addresses this url
136
     *
137
     * @param url url to be converted to file object
138
     * @return file object corresponding to url or null if no one was found
139
     * @since  X.XX
140
     */
141
    public static FileObject findFileObject (URL url) {
142
        FileObject fos[] = URLMapper.findFileObjects(url);
143
        if (fos.length == 0) {
144
            return null;
145
        }
146
        // prefer file object from master filesystem
147
        for (int i=0; i<fos.length; i++) {
148
            if (fos[i].getClass().getName().indexOf("masterfs") != -1) {        //NOI18N
149
                return fos[i];
150
            }
151
        }
152
        return fos[0];
153
    }
154
155
156
    /** Get an array of FileObjects for this url. There is no reason to return array
157
     * with size greater than one because method {@link #findFileObject findFileObject}
158
     * uses just first element (next elements won't be accepted anyway).
159
     * <p class="nonnormative"> There isn't necessary to return array here.
160
     * The only one reason is just backward compatibility.</p>
134
     * @param url to wanted FileObjects
161
     * @param url to wanted FileObjects
135
     * @return a suitable arry of FileObjects, or null
162
     * @return an array of FileObjects with size no greater than one, or null
136
     * @since  2.22*/
163
     * @since  2.22*/
137
    public abstract FileObject[] getFileObjects (URL url);
164
    public abstract FileObject[] getFileObjects (URL url);

Return to bug 41506