Class CombinedResource

java.lang.Object
org.eclipse.jetty.util.resource.Resource
org.eclipse.jetty.util.resource.CombinedResource
All Implemented Interfaces:
Iterable<Resource>

public class CombinedResource extends Resource
Multiple resource directories presented as a single Resource.
  • Method Details

    • getResources

      public List<Resource> getResources()
      Retrieves the resource collection's resources.
      Returns:
      the resource collection
    • resolve

      public Resource resolve(String subUriPath)
      Resolves a path against the resource collection.
      Specified by:
      resolve in class Resource
      Parameters:
      subUriPath - The path segment to resolve
      Returns:
      The resulting resource :
      • is a file that exists in at least one of the collection, then the first one found is returned
      • is a directory that exists in at exactly one of the collection, then that simple directory resource is returned
      • is a directory that exists in several of the collection, then a ResourceCollection of those directories is returned
      • is null if not found in any entry in this collection
    • exists

      public boolean exists()
      Description copied from class: Resource
      Equivalent to Files.exists(Path, LinkOption...) with the following parameters: Resource.getPath() and LinkOption.NOFOLLOW_LINKS.
      Overrides:
      exists in class Resource
      Returns:
      true if the represented resource exists.
    • getPath

      public Path getPath()
      Description copied from class: Resource
      Return the Path corresponding to this resource.
      Specified by:
      getPath in class Resource
      Returns:
      the path.
    • getName

      public String getName()
      Description copied from class: Resource
      The full name of the resource.
      Specified by:
      getName in class Resource
      Returns:
      the full name of the resource, or null if not backed by a Path
    • getFileName

      public String getFileName()
      Description copied from class: Resource

      The file name of the resource.

      This is the last segment of the path.

      Specified by:
      getFileName in class Resource
      Returns:
      the filename of the resource, or "" if there are no path segments (eg: path of "/"), or null if resource has no path.
      See Also:
    • getURI

      public URI getURI()
      Description copied from class: Resource
      URI representing the resource.
      Specified by:
      getURI in class Resource
      Returns:
      a URI representing the given resource
    • isDirectory

      public boolean isDirectory()
      Description copied from class: Resource
      Return true if resource represents a directory of potential resources.
      Specified by:
      isDirectory in class Resource
      Returns:
      true if the represented resource is a container/directory.
    • isReadable

      public boolean isReadable()
      Description copied from class: Resource
      True if the resource is readable.
      Specified by:
      isReadable in class Resource
      Returns:
      true if the represented resource exists, and can read from.
    • lastModified

      public Instant lastModified()
      Description copied from class: Resource
      The time the resource was last modified.
      Overrides:
      lastModified in class Resource
      Returns:
      the last modified time instant, or Instant.EPOCH if unable to obtain last modified.
    • length

      public long length()
      Description copied from class: Resource
      Length of the resource.
      Overrides:
      length in class Resource
      Returns:
      the length of the resource in bytes, or -1L if unable to provide a size (such as a directory resource).
    • iterator

      public Iterator<Resource> iterator()
      Description copied from class: Resource

      Return an Iterator of all Resource's referenced in this Resource.

      This is meaningful if you have a Composite Resource, otherwise it will be a single entry Iterator of this resource.

      Specified by:
      iterator in interface Iterable<Resource>
      Overrides:
      iterator in class Resource
      Returns:
      the iterator of Resources.
    • list

      public List<Resource> list()
      Description copied from class: Resource

      List of contents of a directory Resource.

      Ordering is FileSystem dependent, so callers may wish to sort the return value to ensure deterministic behavior.

      Overrides:
      list in class Resource
      Returns:
      a mutable list of resources contained in the directory resource, or an empty immutable list if unable to build the list (e.g. the resource is not a directory or not readable).
      See Also:
    • copyTo

      public void copyTo(Path destination) throws IOException
      Description copied from class: Resource
      Copy the Resource to the new destination file.

      Will not replace existing destination file.

      Overrides:
      copyTo in class Resource
      Parameters:
      destination - the destination file to create
      Throws:
      IOException - if unable to copy the resource
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      the list of resources
    • isContainedIn

      public boolean isContainedIn(Resource r)
      Description copied from class: Resource
      Return true if this resource is contained in the Resource r, either because r is a folder or a jar file or any form of resource capable of containing other resources.
      Specified by:
      isContainedIn in class Resource
      Parameters:
      r - the containing resource
      Returns:
      true if this Resource is contained, false otherwise