[multiple changes]

2004-09-10  Dalibor Topic <robilad@kaffe.org>

	* gnu/java/net/protocol/file/Connection.java (permission): New field.
	(DEFAULT_PERMISSION): New constant.
	(Connection): Create a FilePermission with permission to read file.

2004-09-10  Michael Koch  <konqueror@gmx.de>

	* gnu/java/net/protocol/file/Connection.java
	(getLastModified): Moved around.
	(getPermission): Return stored permission.

From-SVN: r87291
This commit is contained in:
Michael Koch 2004-09-10 11:06:38 +00:00
parent 8127d0e073
commit cad79bac6c
2 changed files with 46 additions and 22 deletions

View file

@ -1,3 +1,15 @@
2004-09-10 Dalibor Topic <robilad@kaffe.org>
* gnu/java/net/protocol/file/Connection.java (permission): New field.
(DEFAULT_PERMISSION): New constant.
(Connection): Create a FilePermission with permission to read file.
2004-09-10 Michael Koch <konqueror@gmx.de>
* gnu/java/net/protocol/file/Connection.java
(getLastModified): Moved around.
(getPermission): Return stored permission.
2004-09-10 Michael Koch <konqueror@gmx.de> 2004-09-10 Michael Koch <konqueror@gmx.de>
* Makefile.in: Regenerate. * Makefile.in: Regenerate.

View file

@ -68,6 +68,11 @@ import java.util.Locale;
*/ */
public class Connection extends URLConnection public class Connection extends URLConnection
{ {
/**
* Default permission for a file
*/
private static final String DEFAULT_PERMISSION = "read";
/** /**
* HTTP-style DateFormat, used to format the last-modified header. * HTTP-style DateFormat, used to format the last-modified header.
*/ */
@ -92,12 +97,19 @@ public class Connection extends URLConnection
*/ */
private OutputStream outputStream; private OutputStream outputStream;
/**
* FilePermission to read the file
*/
private FilePermission permission;
/** /**
* Calls superclass constructor to initialize. * Calls superclass constructor to initialize.
*/ */
public Connection(URL url) public Connection(URL url)
{ {
super (url); super (url);
permission = new FilePermission(getURL().getFile(), DEFAULT_PERMISSION);
} }
/** /**
@ -186,6 +198,26 @@ public class Connection extends URLConnection
return outputStream; return outputStream;
} }
/**
* Get the last modified time of the resource.
*
* @return the time since epoch that the resource was modified.
*/
public long getLastModified()
{
try
{
if (!connected)
connect();
return file.lastModified();
}
catch (IOException e)
{
return -1;
}
}
/** /**
* Get an http-style header field. Just handle a few common ones. * Get an http-style header field. Just handle a few common ones.
*/ */
@ -235,26 +267,6 @@ public class Connection extends URLConnection
} }
} }
/**
* Get the last modified time of the resource.
*
* @return the time since epoch that the resource was modified.
*/
public long getLastModified()
{
try
{
if (!connected)
connect();
return file.lastModified();
}
catch (IOException e)
{
return -1;
}
}
/** /**
* This method returns a <code>Permission</code> object representing the * This method returns a <code>Permission</code> object representing the
* permissions required to access this URL. This method returns a * permissions required to access this URL. This method returns a
@ -265,6 +277,6 @@ public class Connection extends URLConnection
*/ */
public Permission getPermission() throws IOException public Permission getPermission() throws IOException
{ {
return new FilePermission(getURL().getFile(), "read"); return permission;
} }
} }