Package org.jmxtrans.agent.util.io
Interface Resource
- All Known Implementing Classes:
AbstractResource,ClasspathResource,FileResource,UrlResource
public interface Resource
Inspired by
org.springframework.core.io.Resource.- Author:
- Cyrille Le Clerc
-
Method Summary
Modifier and Type Method Description booleanexists()Return whether this resource actually exists in physical form.StringgetDescription()Return a description for this resource, to be used for error output when working with the resource.FilegetFile()Return a File handle for this resource.InputStreamgetInputStream()Return anInputStream.URIgetURI()Return a URI handle for this resource.URLgetURL()Return a URL handle for this resource.longlastModified()Determine the last-modified timestamp for this resource.
-
Method Details
-
getInputStream
Return anInputStream.It is expected that each call creates a fresh stream.
- Returns:
- the input stream for the underlying resource (must not be
null) - Throws:
IoRuntimeException- if the stream could not be opened
-
exists
boolean exists()Return whether this resource actually exists in physical form.This method performs a definitive existence check, whereas the existence of a
Resourcehandle only guarantees a valid descriptor handle. -
getURL
Return a URL handle for this resource.- Throws:
IoRuntimeException- if the resource cannot be resolved as URL, i.e. if the resource is not available as descriptor
-
getURI
Return a URI handle for this resource.- Throws:
IoRuntimeException- if the resource cannot be resolved as URI, i.e. if the resource is not available as descriptor
-
getFile
Return a File handle for this resource.- Throws:
IoRuntimeException- if the resource cannot be resolved as absolute file path, i.e. if the resource is not available in a file system
-
lastModified
long lastModified()Determine the last-modified timestamp for this resource.- Throws:
IoRuntimeException- if the resource cannot be resolved (in the file system or as some other known physical resource type)
-
getDescription
String getDescription()Return a description for this resource, to be used for error output when working with the resource.Implementations are also encouraged to return this value from their
toStringmethod.- See Also:
Object.toString()
-