KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > internal > core > FileResponse


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.update.internal.core;
12 import java.io.*;
13 import java.net.*;
14
15 import org.eclipse.core.runtime.*;
16
17 public class FileResponse implements Response {
18
19     protected URL url;
20     protected long lastModified;
21
22     public FileResponse(URL url) {
23         this.url = url;
24     }
25
26     public InputStream getInputStream() throws IOException {
27         return url.openStream();
28     }
29
30     public InputStream getInputStream(IProgressMonitor monitor)
31         throws IOException, CoreException {
32         return getInputStream();
33     }
34
35     public long getContentLength() {
36         return 0;
37     }
38
39     public int getStatusCode() {
40         return IStatusCodes.HTTP_OK;
41     }
42
43     public String JavaDoc getStatusMessage() {
44         return ""; //$NON-NLS-1$
45
}
46
47     public long getLastModified() {
48         if (lastModified == 0) {
49             File f = new File(url.getFile());
50             if (f.isDirectory())
51                 f = new File(f, "site.xml"); //$NON-NLS-1$
52
lastModified = f.lastModified();
53         }
54         return lastModified;
55     }
56 }
57
Popular Tags