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 java.lang.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
    boolean exists()
    This implementation checks whether a File can be opened, falling back to whether an InputStream can be opened.
    java.io.File getFile()
    Return a File handle for this resource.
    java.net.URI getURI()
    Return a URI handle for this resource.
    java.net.URL getURL()
    Return a URL handle for this resource.
    long lastModified()
    Determine the last-modified timestamp for this resource.
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.jmxtrans.agent.util.io.Resource

    getDescription, getInputStream
  • 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 java.net.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 java.io.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 java.net.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 java.lang.String toString()
      Overrides:
      toString in class java.lang.Object