source: trunk/greenstone3-extensions/gs3build/src/org/greenstone/gsdl3/gs3build/metadata/METSLocation.java@ 12188

Last change on this file since 12188 was 12188, checked in by kjdon, 18 years ago

Initial revision

  • Property svn:keywords set to Author Date Id Revision
File size: 1.2 KB
Line 
1package org.greenstone.gsdl3.gs3build.metadata;
2
3import java.io.File;
4import java.net.URL;
5import java.net.URLConnection;
6
7import org.greenstone.gsdl3.gs3build.util.URLTools;
8
9public class METSLocation
10{
11 String type;
12 URL location;
13
14 public METSLocation(String type, String location) throws java.net.MalformedURLException
15 { this.type = type;
16 this.location = new URL(location);
17 }
18
19 public METSLocation(URL url)
20 { this.type = "URL";
21 this.location = url;
22 }
23
24 public METSLocation(File file)
25 { this.type = "URL";
26 this.location = URLTools.getFileURL(file);
27 }
28
29 public boolean equals(URL url)
30 { return this.location.equals(url);
31 }
32
33 public URL getLocation()
34 { return this.location;
35 }
36
37 public long getModifiedDatestamp()
38 { if (this.location != null) {
39 if (this.location.getProtocol().equals("file")) {
40 File file = new File(this.location.getPath());
41 return file.lastModified();
42 }
43 else {
44 try {
45 URLConnection connection = this.location.openConnection();
46 return connection.getLastModified();
47 }
48 catch (java.io.IOException io)
49 { // TODO: report error
50 }
51 }
52 }
53 return System.currentTimeMillis();
54 }
55
56 public String getType()
57 { return this.type;
58 }
59}
Note: See TracBrowser for help on using the repository browser.