KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > jayasoft > ivy > repository > ResourceHelper


1 /*
2  * This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
3  * Copyright Jayasoft 2005 - All rights reserved
4  *
5  * #SNAPSHOT#
6  */

7 package fr.jayasoft.ivy.repository;
8
9 import java.io.File JavaDoc;
10 import java.net.MalformedURLException JavaDoc;
11
12 import fr.jayasoft.ivy.repository.file.FileResource;
13 import fr.jayasoft.ivy.repository.url.URLResource;
14
15 public class ResourceHelper {
16     public static boolean equals(Resource res, File JavaDoc f) {
17         if (res == null && f == null) {
18             return true;
19         }
20         if (res == null || f == null) {
21             return false;
22         }
23         if (res instanceof FileResource) {
24             return new File JavaDoc(res.getName()).equals(f);
25         } else if (res instanceof URLResource) {
26             try {
27                 return f.toURL().toExternalForm().equals(res.getName());
28             } catch (MalformedURLException JavaDoc e) {
29                 return false;
30             }
31         }
32         return false;
33     }
34 }
35
Popular Tags