Class ClasspathResource

java.lang.Object
org.jmxtrans.agent.util.io.AbstractResource
org.jmxtrans.agent.util.io.ClasspathResource
All Implemented Interfaces:
Resource

public class ClasspathResource
extends AbstractResource
implements Resource
Resource for classpath:// path.
Author:
Cyrille Le Clerc
  • Constructor Summary

    Constructors
    Constructor Description
    ClasspathResource​(java.lang.String path)  
  • 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.lang.String getDescription()
    Return a description for this resource, to be used for error output when working with the resource.
    java.io.File getFile()
    Return a File handle for this resource.
    java.io.InputStream getInputStream()
    Return an InputStream.
    java.net.URL getURL()
    Return a URL handle for this resource.

    Methods inherited from class org.jmxtrans.agent.util.io.AbstractResource

    getURI, lastModified, 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

    getURI, lastModified
  • Constructor Details

    • ClasspathResource

      public ClasspathResource​(@Nonnull java.lang.String path)
  • Method Details

    • exists

      public boolean exists()
      Description copied from class: AbstractResource
      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
      Overrides:
      exists in class AbstractResource
    • getURL

      @Nonnull public java.net.URL getURL()
      Description copied from interface: Resource
      Return a URL handle for this resource.
      Specified by:
      getURL in interface Resource
      Overrides:
      getURL in class AbstractResource
    • getFile

      @Nonnull public java.io.File getFile()
      Description copied from interface: Resource
      Return a File handle for this resource.
      Specified by:
      getFile in interface Resource
      Overrides:
      getFile in class AbstractResource
    • getInputStream

      @Nonnull public java.io.InputStream getInputStream()
      Description copied from interface: Resource
      Return an InputStream.

      It is expected that each call creates a fresh stream.

      Specified by:
      getInputStream in interface Resource
      Returns:
      the input stream for the underlying resource (must not be null)
    • getDescription

      public java.lang.String getDescription()
      Description copied from interface: Resource
      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 toString method.

      Specified by:
      getDescription in interface Resource
      See Also:
      Object.toString()