aboutsummaryrefslogtreecommitdiff
path: root/libjava/gnu/java
diff options
context:
space:
mode:
authorMichael Koch <konqueror@gmx.de>2003-12-01 15:50:23 +0000
committerMichael Koch <mkoch@gcc.gnu.org>2003-12-01 15:50:23 +0000
commit1fa7e0fd52d115bbe68f138a06d12e7a8adc4be5 (patch)
treeb5fdc38d9379b15233362f18f7b3d559d32a8c46 /libjava/gnu/java
parent3066a15c13e5276734c91eeb573ec17915fed89b (diff)
downloadgcc-1fa7e0fd52d115bbe68f138a06d12e7a8adc4be5.zip
gcc-1fa7e0fd52d115bbe68f138a06d12e7a8adc4be5.tar.gz
gcc-1fa7e0fd52d115bbe68f138a06d12e7a8adc4be5.tar.bz2
2003-12-01 Michael Koch <konqueror@gmx.de>
* gnu/java/net/protocol/file/Connection.java (fileIn): Documentation added. (inputStream): Likewise. (outputStream): Likewise. (Connection): Likewise. (connect): Simplified. From-SVN: r74106
Diffstat (limited to 'libjava/gnu/java')
-rw-r--r--libjava/gnu/java/net/protocol/file/Connection.java61
1 files changed, 53 insertions, 8 deletions
diff --git a/libjava/gnu/java/net/protocol/file/Connection.java b/libjava/gnu/java/net/protocol/file/Connection.java
index 1df5c48..dddbd30 100644
--- a/libjava/gnu/java/net/protocol/file/Connection.java
+++ b/libjava/gnu/java/net/protocol/file/Connection.java
@@ -38,38 +38,71 @@
*/
package gnu.java.net.protocol.file;
-import java.net.URL;
-import java.net.URLConnection;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.FilePermission;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.ProtocolException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.security.Permission;
import java.util.Map;
import java.util.Vector;
import java.util.Hashtable;
import java.util.Enumeration;
/**
+ * This subclass of java.net.URLConnection models a URLConnection via
+ * the "file" protocol.
+ *
+ * @author Aaron M. Renn <arenn@urbanophile.com>
+ * @author Nic Ferrier <nferrier@tapsellferrier.co.uk>
* @author Warren Levy <warrenl@cygnus.com>
- * @date April 13, 1999.
*/
public class Connection extends URLConnection
{
- private Hashtable hdrHash = new Hashtable();
- private Vector hdrVec = new Vector();
- private boolean gotHeaders = false;
+ /**
+ * Default permission for a file
+ */
+ private static final String DEFAULT_PERMISSION = "read";
+
+ /**
+ * This is a File object for this connection
+ */
private File fileIn;
+
+ /**
+ * InputStream if we are reading from the file
+ */
private InputStream inputStream;
+
+ /**
+ * OutputStream if we are writing to the file
+ */
private OutputStream outputStream;
+
+ private Hashtable hdrHash = new Hashtable();
+ private Vector hdrVec = new Vector();
+ private boolean gotHeaders = false;
+ /**
+ * FilePermission to read the file
+ */
+ private FilePermission permission;
+
+ /**
+ * Calls superclass constructor to initialize.
+ */
public Connection(URL url)
{
super (url);
+
+ permission = new FilePermission(getURL().getFile(), DEFAULT_PERMISSION);
}
/**
@@ -82,8 +115,7 @@ public class Connection extends URLConnection
return;
// If not connected, then file needs to be openned.
- String fname = url.getFile();
- fileIn = new File(fname);
+ fileIn = new File(getURL().getFile());
if (doInput)
inputStream = new BufferedInputStream(new FileInputStream(fileIn));
if (doOutput)
@@ -238,4 +270,17 @@ public class Connection extends URLConnection
hdrHash.put(key.toLowerCase(), Long.toString(len));
}
+ /**
+ * This method returns a <code>Permission</code> object representing the
+ * permissions required to access this URL. This method returns a
+ * <code>java.io.FilePermission</code> for the file's path with a read
+ * permission.
+ *
+ * @return A Permission object
+ */
+ public Permission getPermission() throws IOException
+ {
+ return permission;
+ }
+
} // class FileURLConnection