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 Details

    • AbstractResource

      public AbstractResource()
  • Method Details

    • lastModified

      public long lastModified() throws IoRuntimeException
      Description copied from interface: Resource
      Determine the last-modified timestamp for this resource.
      Specified by:
      lastModified in interface Resource
      Throws:
      IoRuntimeException - if the resource cannot be resolved (in the file system or as some other known physical resource type)
    • getURL

      @Nonnull public URL getURL() throws IoRuntimeException
      Description copied from interface: Resource
      Return a URL handle for this resource.
      Specified by:
      getURL in interface Resource
      Throws:
      IoRuntimeException - if the resource cannot be resolved as URL, i.e. if the resource is not available as descriptor
    • getFile

      @Nonnull public File getFile() throws IoRuntimeException
      Description copied from interface: Resource
      Return a File handle for this resource.
      Specified by:
      getFile in interface 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
    • getURI

      @Nonnull public URI getURI() throws IoRuntimeException
      Description copied from interface: Resource
      Return a URI handle for this resource.
      Specified by:
      getURI in interface Resource
      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.
      Specified by:
      exists in interface Resource
    • toString

      public String toString()
      Overrides:
      toString in class Object