|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.mmm.util.resource.base.AbstractDataResource
net.sf.mmm.util.resource.base.UrlResource
public class UrlResource
This is the implementation of the DataResource interface for a
resource that comes from an URL.
| Field Summary | |
|---|---|
private FileUtil |
fileUtil
The FileUtil instance. |
static String |
SCHEME_PREFIX_FTP
The scheme-prefix for FTP. |
static String |
SCHEME_PREFIX_HTTP
The scheme-prefix for HTTP. |
static String |
SCHEME_PREFIX_HTTPS
The scheme-prefix for HTTPS. |
private URL |
url
|
| Constructor Summary | |
|---|---|
UrlResource(String url)
The constructor. |
|
UrlResource(String absolutePath,
FileUtil fileUtil)
The constructor. |
|
UrlResource(URL url)
The constructor. |
|
UrlResource(URL url,
FileUtil fileUtil)
The constructor. |
|
| Method Summary | |
|---|---|
Date |
getLastModificationDate()
This method gets the last modification date of the DataResource if
available and supported. |
String |
getName()
This method gets the name of the resource. |
String |
getPath()
This method gets the path of this resource. |
String |
getSchemePrefix()
This method gets the scheme-prefix of absolute URIs for this type of DataResource. |
URL |
getUrl()
This method gets this resource as URL. |
boolean |
isAvailable()
This method determines if this resource is available. |
boolean |
isData()
This method determines if this resource has potentially data available. |
DataResource |
navigate(String relativePath)
This method creates a new DataResource pointing to the given
resourcePath based on this resource. |
| Methods inherited from class net.sf.mmm.util.resource.base.AbstractDataResource |
|---|
getSize, getUri, isModifiedSince, openOutputStream, openStream, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String SCHEME_PREFIX_HTTP
scheme-prefix for HTTP.
public static final String SCHEME_PREFIX_HTTPS
scheme-prefix for HTTPS.
public static final String SCHEME_PREFIX_FTP
scheme-prefix for FTP.
private final URL url
getUrl()private final FileUtil fileUtil
FileUtil instance.
| Constructor Detail |
|---|
public UrlResource(String url)
url - is the URL to the resource. E.g. "http://foo.bar/index.html".
public UrlResource(String absolutePath,
FileUtil fileUtil)
absolutePath - is the absolute path to the resource. E.g.
"http://foo.bar/index.html".fileUtil - is the FileUtil to use.public UrlResource(URL url)
url - is the URL.
public UrlResource(URL url,
FileUtil fileUtil)
url - is the URL.fileUtil - is the FileUtil to use.| Method Detail |
|---|
public Date getLastModificationDate()
DataResource if
available and supported.
Date or null if not
available or supported.public String getSchemePrefix()
URIs for this type of DataResource. The scheme-prefix has the
following form:
<scheme>:<suffix>
where <suffix> is the empty string or something like
//.
getSchemePrefix in class AbstractDataResourcepublic boolean isAvailable()
data can be read.DataResource.isData() to prevent such expensive operaitons.
isAvailable in interface DataResourceisAvailable in class AbstractDataResourcetrue if this resource is available, false
otherwise.public boolean isData()
available. Unlike DataResource.isAvailable() this method
will not invoke expensive operations like connecting to remote URLs. If
this method will return false, then DataResource.isAvailable()
would also have returned false. However in case of
true only DataResource.isAvailable() can guarantee if a resource
really exists and contains data. E.g. if the resource points to a
File then this method can check if it is a
data-file. So in case it points to a
directory or does not exist at all in the filesystem, this method will
return false. Please also note that this may invoke expensive
operations if the according directory path points to something like a
network share. You should also be aware that the state of DataResource.isData()
and DataResource.isAvailable() can change at any time so you never have a full
guarantee if some data exists or NOT. However in most cases it is very
improbable that this status changes when you read the
resource immediately after the check.
true if this resource points to potential data,
false otherwise.public String getPath()
name of the resource.created.
getPath in interface DataResourcegetPath in class AbstractDataResource
public URL getUrl()
throws ResourceNotAvailableException
URL.
ResourceNotAvailableException - if an URL can NOT be created because
the represented resource does not exist.public String getName()
filename.
getName in interface DataResourcegetName in class AbstractDataResourcepublic DataResource navigate(String relativePath)
DataResource pointing to the given
resourcePath based on this resource.relativePath would be "../apt/sources.list" the resulting
resource would point to "/etc/apt/sources.list".
relativePath - is the absolute or relative path pointing to a new
resource. If it is a relative path, it is interpreted relative to
the parent URI (directory) of this resource.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||