Interface Resource
-
- All Known Subinterfaces:
LocalizableResource
- All Known Implementing Classes:
BasicResource,BuiltFileResource,FileResource,JarResource,LazyResource,SFTPResource,SshResource,URLResource,VsftpResource
public interface ResourceRepresents a resource in an IvyRepository. The resource interface allows one to obtain the following information about a resource:- resource name/identifier in repository syntax
- date the resource was last modified.
- size of the resource in bytes.
- if the resource is available.
Implementation Notes
In implementing the interface you need to ensure the following behaviors:- All of the methods specified in the interface fail by returning an empty value
(
false,0,""). In other words, the specified interface methods should not throw RuntimeExceptions. - Failure conditions should be logged using the
Message.verbose(java.lang.String)method. - Failure of one of the interface's specified methods results in all other interface specified
methods returning an empty value (
false,0,"").
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Resourceclone(java.lang.String cloneName)Clones this resource with a new resource with a different namebooleanexists()Determine if the resource is available.longgetContentLength()Get the resource sizelonggetLastModified()Get the date the resource was last modifiedjava.lang.StringgetName()Get the name of the resource.booleanisLocal()Is this resource local to this host, i.e.java.io.InputStreamopenStream()Opens a stream on this resource
-
-
-
Method Detail
-
getName
java.lang.String getName()
Get the name of the resource.- Returns:
- the repository's assigned resource name/identifier.
-
getLastModified
long getLastModified()
Get the date the resource was last modified- Returns:
- A
longvalue representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or0Lif the file does not exist or if an I/O error occurs.
-
getContentLength
long getContentLength()
Get the resource size- Returns:
- a
longvalue representing the size of the resource in bytes.
-
exists
boolean exists()
Determine if the resource is available. Note that this method only checks for availability, not for actual existence.- Returns:
booleanvalue indicating if the resource is available.
-
isLocal
boolean isLocal()
Is this resource local to this host, i.e. is it on the file system?- Returns:
booleanvalue indicating if the resource is local.
-
clone
Resource clone(java.lang.String cloneName)
Clones this resource with a new resource with a different name- Parameters:
cloneName- the name of the clone- Returns:
- the cloned resource
-
openStream
java.io.InputStream openStream() throws java.io.IOExceptionOpens a stream on this resource- Returns:
- the opened input stream
- Throws:
java.io.IOException- if something goes wrong
-
-