Last change
on this file since 8699 was 7465, checked in by cs025, 20 years ago |
Changes to cope with better file functionality; also proper handling of
Windows file paths with URLTools
|
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.2 KB
|
Rev | Line | |
---|
[5800] | 1 | package org.greenstone.gsdl3.gs3build.metadata;
|
---|
| 2 |
|
---|
| 3 | import java.io.File;
|
---|
| 4 | import java.net.URL;
|
---|
[7465] | 5 | import java.net.URLConnection;
|
---|
[5800] | 6 |
|
---|
[7465] | 7 | import org.greenstone.gsdl3.gs3build.util.URLTools;
|
---|
| 8 |
|
---|
[5800] | 9 | public class METSLocation
|
---|
| 10 | {
|
---|
[5945] | 11 | String type;
|
---|
| 12 | URL location;
|
---|
[5800] | 13 |
|
---|
[5945] | 14 | public METSLocation(String type, String location) throws java.net.MalformedURLException
|
---|
| 15 | { this.type = type;
|
---|
| 16 | this.location = new URL(location);
|
---|
| 17 | }
|
---|
[5800] | 18 |
|
---|
[5945] | 19 | public METSLocation(URL url)
|
---|
| 20 | { this.type = "URL";
|
---|
| 21 | this.location = url;
|
---|
| 22 | }
|
---|
[5800] | 23 |
|
---|
[7465] | 24 | public METSLocation(File file)
|
---|
[5945] | 25 | { this.type = "URL";
|
---|
[7465] | 26 | this.location = URLTools.getFileURL(file);
|
---|
[5945] | 27 | }
|
---|
[5800] | 28 |
|
---|
[5945] | 29 | public boolean equals(URL url)
|
---|
| 30 | { return this.location.equals(url);
|
---|
| 31 | }
|
---|
[5800] | 32 |
|
---|
[5945] | 33 | public URL getLocation()
|
---|
| 34 | { return this.location;
|
---|
| 35 | }
|
---|
| 36 |
|
---|
[7465] | 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 |
|
---|
[5945] | 56 | public String getType()
|
---|
| 57 | { return this.type;
|
---|
| 58 | }
|
---|
| 59 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.