Groovy Documentation

org.codehaus.groovy.grails.io.support
[Java] Class UrlResource

java.lang.Object
  org.codehaus.groovy.grails.io.support.AbstractFileResolvingResource
      org.codehaus.groovy.grails.io.support.UrlResource

public class UrlResource
extends AbstractFileResolvingResource

Resource implementation for java.net.URL locators. Obviously supports resolution as URL, and also as File in case of the "file:" protocol.

Authors:
Juergen Hoeller
See Also:
java.net.URL
Since:
28.12.2003


Constructor Summary
UrlResource(java.net.URL url)

Create a new UrlResource.

UrlResource(java.net.URI uri)

Create a new UrlResource.

UrlResource(java.lang.String path)

Create a new UrlResource.

 
Method Summary
Resource createRelative(java.lang.String relativePath)

This implementation creates a UrlResource, applying the given path relative to the path of the underlying URL of this resource descriptor.

boolean equals(java.lang.Object obj)

This implementation compares the underlying URL references.

java.lang.String getDescription()

This implementation returns a description that includes the URL.

java.io.File getFile()

This implementation returns a File reference for the underlying URL/URI, provided that it refers to a file in the file system.

java.lang.String getFilename()

This implementation returns the name of the file that this URL refers to.

java.io.InputStream getInputStream()

This implementation opens an InputStream for the given URL.

java.net.URI getURI()

This implementation returns the underlying URI directly, if possible.

java.net.URL getURL()

This implementation returns the underlying URL reference.

int hashCode()

This implementation returns the hash code of the underlying URL reference.

java.lang.String toString()

 
Methods inherited from class AbstractFileResolvingResource
contentLength, exists, getFile, getFile, getFileForLastModifiedCheck, isReadable, lastModified
 
Methods inherited from class java.lang.Object
java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Constructor Detail

UrlResource

public UrlResource(java.net.URL url)
Create a new UrlResource.
Parameters:
url - a URL


UrlResource

public UrlResource(java.net.URI uri)
Create a new UrlResource.
throws:
java.net.MalformedURLException if the given URL path is not valid
Parameters:
uri - a URI


UrlResource

public UrlResource(java.lang.String path)
Create a new UrlResource.
throws:
MalformedURLException if the given URL path is not valid
Parameters:
path - a URL path


 
Method Detail

createRelative

public Resource createRelative(java.lang.String relativePath)
This implementation creates a UrlResource, applying the given path relative to the path of the underlying URL of this resource descriptor.
See Also:
java.net.URL#URL(java.net.URL, String)


equals

(obj instanceof UrlResource && cleanedUrl.equals(((UrlResource) obj).cleanedUrl)));
public boolean equals(java.lang.Object obj)
This implementation compares the underlying URL references.


getDescription

public java.lang.String getDescription()
This implementation returns a description that includes the URL.


getFile

}
public java.io.File getFile()
This implementation returns a File reference for the underlying URL/URI, provided that it refers to a file in the file system.


getFilename

public java.lang.String getFilename()
This implementation returns the name of the file that this URL refers to.
See Also:
java.net.URL#getFile()
java.io.File#getName()


getInputStream

public java.io.InputStream getInputStream()
This implementation opens an InputStream for the given URL. It sets the "UseCaches" flag to false, mainly to avoid jar file locking on Windows.
See Also:
java.net.URL#openConnection()
java.net.URLConnection#setUseCaches(boolean)
java.net.URLConnection#getInputStream()


getURI

public java.net.URI getURI()
This implementation returns the underlying URI directly, if possible.


getURL

public java.net.URL getURL()
This implementation returns the underlying URL reference.


hashCode

}
public int hashCode()
This implementation returns the hash code of the underlying URL reference.


toString

}
}
public java.lang.String toString()


 

Groovy Documentation