org.mortbay.util

Class URLResource

public class URLResource extends Resource

Abstract resource class.

Version: $Id: URLResource.java,v 1.9 2005/08/13 00:01:28 gregwilkins Exp $

Author: Nuno Preguiga Greg Wilkins (gregw)

Field Summary
protected URLConnection_connection
protected InputStream_in
protected URL_url
protected String_urlString
Constructor Summary
protected URLResource(URL url, URLConnection connection)
Method Summary
ResourceaddPath(String path)
Returns the resource contained inside the current resource with the given name
protected booleancheckConnection()
booleandelete()
Deletes the given resource
booleanequals(Object o)
booleanexists()
Returns true if the respresened resource exists.
FilegetFile()
Returns an File representing the given resource or NULL if this is not possible.
InputStreamgetInputStream()
Returns an input stream to the resource
StringgetName()
Returns the name of the resource
OutputStreamgetOutputStream()
Returns an output stream to the resource
URLgetURL()
Returns an URL representing the given resource
inthashCode()
booleanisDirectory()
Returns true if the respresenetd resource is a container/directory.
longlastModified()
Returns the last modified time
longlength()
Return the length of the resource
String[]list()
Returns a list of resource names contained in the given resource
voidrelease()
Release any resources held by the resource.
booleanrenameTo(Resource dest)
Rename the given resource
StringtoString()

Field Detail

_connection

protected transient URLConnection _connection

_in

protected transient InputStream _in

_url

protected URL _url

_urlString

protected String _urlString

Constructor Detail

URLResource

protected URLResource(URL url, URLConnection connection)

Method Detail

addPath

public Resource addPath(String path)
Returns the resource contained inside the current resource with the given name

checkConnection

protected boolean checkConnection()

delete

public boolean delete()
Deletes the given resource

equals

public boolean equals(Object o)

exists

public boolean exists()
Returns true if the respresened resource exists.

getFile

public File getFile()
Returns an File representing the given resource or NULL if this is not possible.

getInputStream

public InputStream getInputStream()
Returns an input stream to the resource

getName

public String getName()
Returns the name of the resource

getOutputStream

public OutputStream getOutputStream()
Returns an output stream to the resource

getURL

public URL getURL()
Returns an URL representing the given resource

hashCode

public int hashCode()

isDirectory

public boolean isDirectory()
Returns true if the respresenetd resource is a container/directory. If the resource is not a file, resources ending with "/" are considered directories.

lastModified

public long lastModified()
Returns the last modified time

length

public long length()
Return the length of the resource

list

public String[] list()
Returns a list of resource names contained in the given resource

release

public void release()
Release any resources held by the resource.

renameTo

public boolean renameTo(Resource dest)
Rename the given resource

toString

public String toString()
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.