Interface ResourceId

All Superinterfaces:
Serializable
All Known Implementing Classes:
ClassLoaderFileSystem.ClassLoaderResourceId, GcsResourceId

public interface ResourceId extends Serializable
An identifier which represents a file-like resource.

ResourceId is hierarchical and composed of a sequence of directory and file name elements separated by a special separator or delimiter.

ResourceIds are created using FileSystems. The two primary mechanisms are:

  • Method Details

    • resolve

      ResourceId resolve(String other, ResolveOptions resolveOptions)
      Returns a child ResourceId under this.

      In order to write file system agnostic code, callers should not include delimiters in other, and should use ResolveOptions.StandardResolveOptions to specify whether to resolve a file or a directory.

      For example:

      
       ResourceId homeDir = ...;
       ResourceId tempOutput = homeDir
           .resolve("tempDir", StandardResolveOptions.RESOLVE_DIRECTORY)
           .resolve("output", StandardResolveOptions.RESOLVE_FILE);
       

      This ResourceId should represents a directory.

      It is up to each file system to resolve in their own way.

      Resolving special characters:

      • resourceId.resolve("..", StandardResolveOptions.RESOLVE_DIRECTORY) returns the parent directory of this ResourceId.
      • resourceId.resolve("*", StandardResolveOptions.RESOLVE_FILE) returns a ResourceId which matches all files in this ResourceId.
      • resourceId.resolve("*", StandardResolveOptions.RESOLVE_DIRECTORY) returns a ResourceId which matches all directories in this ResourceId.
      Throws:
      IllegalStateException - if this ResourceId is not a directory.
      IllegalArgumentException - if other contains illegal characters or is an illegal name. It is recommended that callers use common characters, such as [_a-zA-Z0-9.-], in other.
    • getCurrentDirectory

      ResourceId getCurrentDirectory()
      Returns the ResourceId that represents the current directory of this ResourceId.

      If it is already a directory, trivially returns this.

    • getScheme

      String getScheme()
      Get the scheme which defines the namespace of the ResourceId.

      The scheme is required to follow URI scheme syntax. See RFC 2396

    • getFilename

      @Nullable String getFilename()
      Returns the name of the file or directory denoted by this ResourceId. The file name is the farthest element from the root in the directory hierarchy.
      Returns:
      a string representing the name of file or directory, or null if there are zero components.
    • isDirectory

      boolean isDirectory()
      Returns true if this ResourceId represents a directory, false otherwise.
    • toString

      String toString()
      Returns the string representation of this ResourceId.

      The corresponding FileSystem.match(java.util.List<java.lang.String>) is required to accept this string representation.

      Overrides:
      toString in class Object