Package org.jmxtrans.agent.util.io
Class AbstractResource
java.lang.Object
org.jmxtrans.agent.util.io.AbstractResource
- All Implemented Interfaces:
Resource
- Direct Known Subclasses:
ClasspathResource,FileResource,UrlResource
public abstract class AbstractResource extends Object implements Resource
Inspired by
org.springframework.core.io.AbstractResource- Author:
- Cyrille Le Clerc
-
Constructor Summary
Constructors Constructor Description AbstractResource() -
Method Summary
Modifier and Type Method Description booleanexists()This implementation checks whether a File can be opened, falling back to whether an InputStream can be opened.FilegetFile()Return a File handle for this resource.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.StringtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jmxtrans.agent.util.io.Resource
getDescription, getInputStream
-
Constructor Details
-
AbstractResource
public AbstractResource()
-
-
Method Details
-
lastModified
Description copied from interface:ResourceDetermine the last-modified timestamp for this resource.- Specified by:
lastModifiedin interfaceResource- Throws:
IoRuntimeException- if the resource cannot be resolved (in the file system or as some other known physical resource type)
-
getURL
Description copied from interface:ResourceReturn a URL handle for this resource.- Specified by:
getURLin interfaceResource- Throws:
IoRuntimeException- if the resource cannot be resolved as URL, i.e. if the resource is not available as descriptor
-
getFile
Description copied from interface:ResourceReturn a File handle for this resource.- Specified by:
getFilein interfaceResource- Throws:
IoRuntimeException- if the resource cannot be resolved as absolute file path, i.e. if the resource is not available in a file system
-
getURI
Description copied from interface:ResourceReturn a URI handle for this resource.- Specified by:
getURIin interfaceResource- Throws:
IoRuntimeException- if the resource cannot be resolved as URI, i.e. if the resource is not available as descriptor
-
exists
public boolean exists()This implementation checks whether a File can be opened, falling back to whether an InputStream can be opened. This will cover both directories and content resources. -
toString
-