Class JavaResource

All Implemented Interfaces:
Cloneable, Comparable<Resource>, Iterable<Resource>, ResourceCollection, URLProvider

public class JavaResource extends AbstractClasspathResource implements URLProvider
A Resource representation of something loadable via a Java classloader.
Since:
Ant 1.7
  • Constructor Details

    • JavaResource

      public JavaResource()
      Default constructor.
    • JavaResource

      public JavaResource(String name, Path path)
      Construct a new JavaResource using the specified name and classpath.
      Parameters:
      name - the resource name.
      path - the classpath.
  • Method Details

    • openInputStream

      protected InputStream openInputStream(ClassLoader cl) throws IOException
      open the input stream from a specific classloader
      Specified by:
      openInputStream in class AbstractClasspathResource
      Parameters:
      cl - the classloader to use. Will be null if the system classloader is used
      Returns:
      an open input stream for the resource
      Throws:
      IOException - if an error occurs.
    • getURL

      public URL getURL()
      Get the URL represented by this Resource.
      Specified by:
      getURL in interface URLProvider
      Returns:
      the file.
      Since:
      Ant 1.8.0
    • compareTo

      public int compareTo(Resource another)
      Compare this JavaResource to another Resource.
      Specified by:
      compareTo in interface Comparable<Resource>
      Overrides:
      compareTo in class Resource
      Parameters:
      another - the other Resource against which to compare.
      Returns:
      a negative integer, zero, or a positive integer as this JavaResource is less than, equal to, or greater than the specified Resource.
    • getRef

      protected JavaResource getRef()
      Description copied from class: Resource
      Perform the check for circular references and return the referenced Resource.
      Overrides:
      getRef in class AbstractClasspathResource
      Returns:
      Resource.