| 1 6 package fr.jayasoft.ivy; 7 8 import java.io.IOException ; 9 import java.net.HttpURLConnection ; 10 import java.net.URL ; 11 import java.net.URLConnection ; 12 13 import fr.jayasoft.ivy.util.Message; 14 15 public class ResolvedURL implements ArtifactInfo { 16 URL url; 17 String revision; 18 private Long _lastModified; 19 20 public ResolvedURL(URL url, String revision) { 21 this.url = url; 22 this.revision = revision; 23 } 24 25 public String toString() { 26 return url + "(" + revision + ")"; 27 } 28 29 public String getRevision() { 30 return revision; 31 } 32 33 public long getLastModified() { 34 if (_lastModified == null) { 35 URLConnection con = null; 36 try { 37 con = url.openConnection(); 38 _lastModified = new Long (con.getLastModified()); 39 } catch (IOException e) { 40 Message.warn("impossible to open connection to "+url+": "+e.getMessage()); 41 _lastModified = new Long (0); 42 } finally { 43 if (con instanceof HttpURLConnection ) { 44 ((HttpURLConnection )con).disconnect(); 45 } 46 } 47 } 48 return _lastModified.longValue(); 49 } 50 51 public URL getURL() { 52 return url; 53 } 54 } 55 | Popular Tags |