Class AbstractResource

All Implemented Interfaces:
Direct Known Subclasses:
MockResource, PathResource, ResourceAccessor.NotFoundResource, URIResource

public abstract class AbstractResource extends Object implements Resource
  • Constructor Details

    • AbstractResource

      public AbstractResource(String path, URI uri)
  • Method Details

    • getPath

      public String getPath()
      Description copied from interface: Resource
      Returns the normalized, ResourceAccessor-relative path for this resource. To get the unique location of this resource, use Resource.getUri() This should always use `/` for separators This should not include any sort of protocol or prefixes This should not have a leading /. This should have any relative paths smoothed out -- return "path/to/resource" not "path/from/../to/resource".
      Specified by:
      getPath in interface Resource
    • getUri

      public URI getUri()
      Description copied from interface: Resource
      Returns a unique and complete identifier for this resource. This will be different than what is returned by Resource.getPath() because the path within the resource accessor whereas this is the a complete path to it.

      For example, a file resource may return a path of my/file.txt and a uri of file:/tmp/project/liquibase/my/file.txt for a resource accessor using file:/tmp/project/liquibase as a root

      Specified by:
      getUri in interface Resource
    • isWritable

      public boolean isWritable()
      Description copied from interface: Resource
      Return true if the resource can be written to
      Specified by:
      isWritable in interface Resource
    • openOutputStream

      public OutputStream openOutputStream(OpenOptions openOptions) throws IOException
      Description copied from interface: Resource
      Opens an output stream given the passed OpenOptions. Cannot pass a null OpenOptions value
      Specified by:
      openOutputStream in interface Resource
    • toString

      public String toString()
      toString in class Object
    • hashCode

      public int hashCode()
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      equals in class Object
    • resolvePath

      protected String resolvePath(String other)
      Convenience method for computing the relative path in Resource.resolve(String) implementations
    • resolveSiblingPath

      protected String resolveSiblingPath(String other)
      Convenience method for computing the relative path in Resource.resolveSibling(String) implementations.