Lines 273-278
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. |
Lines 281-286
Link Here
|
281 |
* @return corresponding FileObjects or empty array if no |
292 |
* @return corresponding FileObjects or empty array if no |
282 |
* corresponding FileObject exists. |
293 |
* corresponding FileObject exists. |
283 |
* @since 1.29 |
294 |
* @since 1.29 |
|
|
295 |
* @deprecated Use method {@link #toFileObject toFileObject} |
284 |
*/ |
296 |
*/ |
285 |
public static FileObject[] fromFile (File file) { |
297 |
public static FileObject[] fromFile (File file) { |
286 |
if (!file.equals(normalizeFile(file))) { |
298 |
if (!file.equals(normalizeFile(file))) { |
Lines 826-854
Link Here
|
826 |
} |
838 |
} |
827 |
/** |
839 |
/** |
828 |
* This method is very similar to URLMapper.findFileObjects(URL) with |
|
|
829 |
* difference that it returns just one file object and that it knows |
830 |
* which file object must be used from available ones. |
831 |
* |
832 |
* @param url url to be converted to file object |
833 |
* @return file object corresponding to url or null if no one was found |
834 |
* @since XXX |
835 |
*/ |
836 |
public static FileObject findFileObject(URL url) { |
837 |
FileObject fos[] = URLMapper.findFileObjects(url); |
838 |
if (fos.length == 0) { |
839 |
return null; |
840 |
} |
841 |
// prefer file object from master filesystem |
842 |
for (int i=0; i<fos.length; i++) { |
843 |
if (fos[i].getClass().getName().indexOf("masterfs") != -1) { //NOI18N |
844 |
return fos[i]; |
845 |
} |
846 |
} |
847 |
return fos[0]; |
848 |
} |
849 |
|
850 |
/** |
851 |
* Returns a FileObject of the root of an jar/zip archive |
840 |
* Returns a FileObject of the root of an jar/zip archive |
852 |
* given be an argument. |
841 |
* given be an argument. |
853 |
* @param fo FileObject of the zip/jar archive file |
842 |
* @param fo FileObject of the zip/jar archive file |
Lines 860-866
Link Here
|
860 |
if (archiveURL == null) { |
849 |
if (archiveURL == null) { |
861 |
return null; |
850 |
return null; |
862 |
} |
851 |
} |
863 |
return findFileObject(getArchiveRoot(archiveURL)); |
852 |
return URLMapper.findFileObject(getArchiveRoot(archiveURL)); |
864 |
} |
853 |
} |
865 |
/** |
854 |
/** |
Lines 968-974
Link Here
|
968 |
* @since XXX |
957 |
* @since XXX |
969 |
*/ |
958 |
*/ |
970 |
public static boolean isArchiveFile (URL url) { |
959 |
public static boolean isArchiveFile (URL url) { |
971 |
FileObject fo = findFileObject(url); |
960 |
FileObject fo = URLMapper.findFileObject(url); |
972 |
if (fo!=null) { |
961 |
if (fo!=null) { |
973 |
return isArchiveFile(fo); |
962 |
return isArchiveFile(fo); |
974 |
} |
963 |
} |