public class UrlResource extends AbstractResource
Title: UrlResource.java
Description:
bboss workgroup
Copyright (c) 2007
savesize| Constructor and Description |
|---|
UrlResource(java.lang.String path)
Create a new UrlResource.
|
UrlResource(java.net.URI uri)
Create a new UrlResource.
|
UrlResource(java.net.URL url)
Create a new UrlResource.
|
| Modifier and Type | Method and Description |
|---|---|
long |
contentLength()
This implementation checks the timestamp of the underlying File,
if available.
|
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.
|
protected java.io.File |
getFileForLastModifiedCheck()
This implementation determines the underlying File
(or jar file, in case of a resource in a jar/zip).
|
java.lang.String |
getFilename()
This implementation returns the name of the file that this URL refers to.
|
long |
getHeaderFieldLong(java.lang.String name,
long Default) |
java.io.InputStream |
getInputStream()
This implementation opens an InputStream for the given URL.
|
long |
getTotalsize() |
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.
|
void |
open() |
void |
open(boolean reopen) |
void |
release() |
exists, getSavesize, isOpen, isReadable, lastModified, savetofile, savetofile, toStringpublic UrlResource(java.net.URL url)
url - a URLpublic UrlResource(java.net.URI uri)
throws java.net.MalformedURLException
uri - a URIjava.net.MalformedURLException - if the given URL path is not validpublic UrlResource(java.lang.String path)
throws java.net.MalformedURLException
path - a URL pathjava.net.MalformedURLException - if the given URL path is not validpublic void open()
throws java.io.IOException
java.io.IOExceptionpublic void open(boolean reopen)
throws java.io.IOException
java.io.IOExceptionpublic long getHeaderFieldLong(java.lang.String name,
long Default)
public java.io.InputStream getInputStream()
throws java.io.IOException
false,
mainly to avoid jar file locking on Windows.java.io.IOException - if the stream could not be openedURL.openConnection(),
URLConnection.setUseCaches(boolean),
URLConnection.getInputStream()public java.net.URL getURL()
throws java.io.IOException
getURL in interface ResourcegetURL in class AbstractResourcejava.io.IOException - if the resource cannot be resolved as URL,
i.e. if the resource is not available as descriptorpublic java.net.URI getURI()
throws java.io.IOException
getURI in interface ResourcegetURI in class AbstractResourcejava.io.IOException - if the resource cannot be resolved as URI,
i.e. if the resource is not available as descriptorpublic java.io.File getFile()
throws java.io.IOException
getFile in interface ResourcegetFile in class AbstractResourcejava.io.IOException - if the resource cannot be resolved as absolute
file path, i.e. if the resource is not available in a file systemResourceUtils.getFile(java.net.URL, String)protected java.io.File getFileForLastModifiedCheck()
throws java.io.IOException
getFileForLastModifiedCheck in class AbstractResourcenull)java.io.IOException - if the resource cannot be resolved as absolute
file path, i.e. if the resource is not available in a file systempublic Resource createRelative(java.lang.String relativePath) throws java.net.MalformedURLException
createRelative in interface ResourcecreateRelative in class AbstractResourcerelativePath - the relative path (relative to this resource)java.net.MalformedURLExceptionURL.URL(java.net.URL, String)public java.lang.String getFilename()
getFilename in interface ResourcegetFilename in class AbstractResourceURL.getFile(),
File.getName()public java.lang.String getDescription()
Object.toString()public boolean equals(java.lang.Object obj)
equals in class AbstractResourceResource.getDescription()public int hashCode()
hashCode in class AbstractResourceResource.getDescription()public void release()
release in interface Resourcerelease in class AbstractResourcepublic long contentLength()
throws java.io.IOException
contentLength in interface ResourcecontentLength in class AbstractResourcejava.io.IOException - if the resource cannot be resolved
(in the file system or as some other known physical resource type)getFile()public long getTotalsize()