Commit 84ebbc67 by Michael Koch Committed by Michael Koch

Connection.java: Some reformating.

2003-12-02  Michael Koch  <konqueror@gmx.de>

	* gnu/java/net/protocol/file/Connection.java:
	Some reformating.
	(file): Renamed from fileIn.
	(getPermission): Moved around.

From-SVN: r74179
parent 83f85f9c
2003-12-02 Michael Koch <konqueror@gmx.de> 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 * gnu/java/net/protocol/jar/Connection.java
(Connection): Made class final, merged documentation with classpath. (Connection): Made class final, merged documentation with classpath.
(file_cache): Made private. (file_cache): Made private.
......
...@@ -74,7 +74,7 @@ public class Connection extends URLConnection ...@@ -74,7 +74,7 @@ public class Connection extends URLConnection
/** /**
* This is a File object for this connection * This is a File object for this connection
*/ */
private File fileIn; private File file;
/** /**
* InputStream if we are reading from the file * InputStream if we are reading from the file
...@@ -115,11 +115,12 @@ public class Connection extends URLConnection ...@@ -115,11 +115,12 @@ public class Connection extends URLConnection
return; return;
// If not connected, then file needs to be openned. // If not connected, then file needs to be openned.
fileIn = new File(getURL().getFile()); file = new File (getURL().getFile());
if (doInput) if (doInput)
inputStream = new BufferedInputStream(new FileInputStream(fileIn)); inputStream = new BufferedInputStream(new FileInputStream(file));
if (doOutput) if (doOutput)
outputStream = new BufferedOutputStream(new FileOutputStream(fileIn)); outputStream = new BufferedOutputStream(new FileOutputStream(file));
connected = true; connected = true;
} }
...@@ -134,8 +135,9 @@ public class Connection extends URLConnection ...@@ -134,8 +135,9 @@ public class Connection extends URLConnection
public InputStream getInputStream() public InputStream getInputStream()
throws IOException throws IOException
{ {
if (! doInput) if (!doInput)
throw new ProtocolException("Can't open InputStream if doInput is false"); throw new ProtocolException("Can't open InputStream if doInput is false");
if (!connected) if (!connected)
connect(); connect();
...@@ -152,7 +154,7 @@ public class Connection extends URLConnection ...@@ -152,7 +154,7 @@ public class Connection extends URLConnection
public OutputStream getOutputStream() public OutputStream getOutputStream()
throws IOException throws IOException
{ {
if (! doOutput) if (!doOutput)
throw new throw new
ProtocolException("Can't open OutputStream if doOutput is false"); ProtocolException("Can't open OutputStream if doOutput is false");
...@@ -163,6 +165,19 @@ public class Connection extends URLConnection ...@@ -163,6 +165,19 @@ public class Connection extends URLConnection
} }
// Override default method in URLConnection. // 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) public String getHeaderField(String name)
{ {
try try
...@@ -176,7 +191,6 @@ public class Connection extends URLConnection ...@@ -176,7 +191,6 @@ public class Connection extends URLConnection
return (String) hdrHash.get(name.toLowerCase()); return (String) hdrHash.get(name.toLowerCase());
} }
// Override default method in URLConnection.
public Map getHeaderFields() public Map getHeaderFields()
{ {
try try
...@@ -190,7 +204,6 @@ public class Connection extends URLConnection ...@@ -190,7 +204,6 @@ public class Connection extends URLConnection
return hdrHash; return hdrHash;
} }
// Override default method in URLConnection.
public String getHeaderField(int n) public String getHeaderField(int n)
{ {
try try
...@@ -207,7 +220,6 @@ public class Connection extends URLConnection ...@@ -207,7 +220,6 @@ public class Connection extends URLConnection
return null; return null;
} }
// Override default method in URLConnection.
public String getHeaderFieldKey(int n) public String getHeaderFieldKey(int n)
{ {
try try
...@@ -259,7 +271,7 @@ public class Connection extends URLConnection ...@@ -259,7 +271,7 @@ public class Connection extends URLConnection
// to add others later and for consistency, we'll implement it this way. // to add others later and for consistency, we'll implement it this way.
// Add the only header we know about right now: Content-length. // Add the only header we know about right now: Content-length.
long len = fileIn.length(); long len = file.length();
String line = "Content-length: " + len; String line = "Content-length: " + len;
hdrVec.addElement(line); hdrVec.addElement(line);
...@@ -269,18 +281,5 @@ public class Connection extends URLConnection ...@@ -269,18 +281,5 @@ public class Connection extends URLConnection
String key = getKey(line); String key = getKey(line);
hdrHash.put(key.toLowerCase(), Long.toString(len)); 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 } // class FileURLConnection
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment