KickJava   Java API By Example, From Geeks To Geeks.

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


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