This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
FYI: Patch: gnu.java.net.protocol.file.Connection
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 2 Dec 2003 16:34:13 +0100
- Subject: FYI: Patch: gnu.java.net.protocol.file.Connection
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi list,
I commited the attached patch to get
gnu.java.net.protocol.file.Connection more in line with classpath.
Michael
- --
Homepage: http://www.worldforge.org/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)
iD8DBQE/zLD1WSOgCCdjSDsRAlBMAJ4sEZO3PFBoPzMNq9APvMGbDYSyyQCghlh6
n/JJPcpqZIrzAWecE63aezI=
=O3e7
-----END PGP SIGNATURE-----
Index: ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/libjava/ChangeLog,v
retrieving revision 1.2398
diff -u -b -B -r1.2398 ChangeLog
--- ChangeLog 2 Dec 2003 14:19:32 -0000 1.2398
+++ ChangeLog 2 Dec 2003 14:27:13 -0000
@@ -1,5 +1,12 @@
2003-12-02 Michael Koch <konqueror@gmx.de>
+ * gnu/java/net/protocol/file/Connection.java:
+ Some reformating.
+ (file): Renamed from fileIn.
+ (getPermission): Moved around.
+
+2003-12-02 Michael Koch <konqueror@gmx.de>
+
* gnu/java/net/protocol/jar/Connection.java
(Connection): Made class final, merged documentation with classpath.
(file_cache): Made private.
Index: gnu/java/net/protocol/file/Connection.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/net/protocol/file/Connection.java,v
retrieving revision 1.3
diff -u -b -B -r1.3 Connection.java
--- gnu/java/net/protocol/file/Connection.java 1 Dec 2003 15:50:23 -0000 1.3
+++ gnu/java/net/protocol/file/Connection.java 2 Dec 2003 14:27:13 -0000
@@ -74,7 +74,7 @@
/**
* This is a File object for this connection
*/
- private File fileIn;
+ private File file;
/**
* InputStream if we are reading from the file
@@ -115,11 +115,12 @@
return;
// If not connected, then file needs to be openned.
- fileIn = new File(getURL().getFile());
+ file = new File (getURL().getFile());
if (doInput)
- inputStream = new BufferedInputStream(new FileInputStream(fileIn));
+ inputStream = new BufferedInputStream(new FileInputStream(file));
+
if (doOutput)
- outputStream = new BufferedOutputStream(new FileOutputStream(fileIn));
+ outputStream = new BufferedOutputStream(new FileOutputStream(file));
connected = true;
}
@@ -134,8 +135,9 @@
public InputStream getInputStream()
throws IOException
{
- if (! doInput)
+ if (!doInput)
throw new ProtocolException("Can't open InputStream if doInput is false");
+
if (!connected)
connect();
@@ -152,7 +154,7 @@
public OutputStream getOutputStream()
throws IOException
{
- if (! doOutput)
+ if (!doOutput)
throw new
ProtocolException("Can't open OutputStream if doOutput is false");
@@ -163,6 +165,19 @@
}
// Override default method in URLConnection.
+ /**
+ * 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;
+ }
+
public String getHeaderField(String name)
{
try
@@ -176,7 +191,6 @@
return (String) hdrHash.get(name.toLowerCase());
}
- // Override default method in URLConnection.
public Map getHeaderFields()
{
try
@@ -190,7 +204,6 @@
return hdrHash;
}
- // Override default method in URLConnection.
public String getHeaderField(int n)
{
try
@@ -207,7 +220,6 @@
return null;
}
- // Override default method in URLConnection.
public String getHeaderFieldKey(int n)
{
try
@@ -259,7 +271,7 @@
// to add others later and for consistency, we'll implement it this way.
// Add the only header we know about right now: Content-length.
- long len = fileIn.length();
+ long len = file.length();
String line = "Content-length: " + len;
hdrVec.addElement(line);
@@ -268,19 +280,6 @@
// else, then we may have to check if the result of getKey() is null.
String key = getKey(line);
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