Package org.eclipse.jetty.util.resource
Class CombinedResource
java.lang.Object
org.eclipse.jetty.util.resource.Resource
org.eclipse.jetty.util.resource.CombinedResource
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Return true if this resource deeply contains the other Resource.void
Copy the Resource to the new destination file or directory.boolean
boolean
exists()
Equivalent toFiles.exists(Path, LinkOption...)
with the following parameters:Resource.getPath()
andLinkOption.NOFOLLOW_LINKS
.The file name of the resource.getName()
The full name of the resource.getPath()
Return the Path corresponding to this resource.Get the relative path from this Resource to a possibly contained resource.The real URI of the resource.Retrieves the resource collection's resources.getURI()
URI representing the resource.int
hashCode()
boolean
isAlias()
boolean
Return true if resource represents a directory of potential resources.boolean
True if the resource is readable.boolean
isSameFile
(Path path) iterator()
Return an Iterator of all Resource's referenced in this Resource.The time the resource was last modified.long
length()
Length of the resource.list()
List of contents of a directoryResource
.Resolves a path against the resource collection.toString()
Methods inherited from class org.eclipse.jetty.util.resource.Resource
dump, getAllResources, isContainedIn, newInputStream, newReadableByteChannel
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
getResources
Retrieves the resource collection's resources.- Returns:
- the resource collection
-
resolve
Resolves a path against the resource collection.- Specified by:
resolve
in classResource
- 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 toFiles.exists(Path, LinkOption...)
with the following parameters:Resource.getPath()
andLinkOption.NOFOLLOW_LINKS
. -
getPath
Description copied from class:Resource
Return the Path corresponding to this resource. -
getName
Description copied from class:Resource
The full name of the resource. -
getFileName
Description copied from class:Resource
The file name of the resource.
This is the last segment of the path.
- Specified by:
getFileName
in classResource
- Returns:
- the filename of the resource, or "" if there are no path segments (eg: path of "/"), or null if resource cannot determine a filename.
- See Also:
-
getURI
Description copied from class:Resource
URI representing the resource. -
isDirectory
public boolean isDirectory()Description copied from class:Resource
Return true if resource represents a directory of potential resources.- Specified by:
isDirectory
in classResource
- 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 classResource
- Returns:
- true if the represented resource exists, and can read from.
-
lastModified
Description copied from class:Resource
The time the resource was last modified.- Overrides:
lastModified
in classResource
- 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. -
iterator
Description copied from class:Resource
Return an Iterator of all Resource's referenced in this Resource.
This is meaningful if you have a
CombinedResource
, otherwise it will be a single entry Iterator of this 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. -
copyTo
Description copied from class:Resource
Copy the Resource to the new destination file or directory.If this Resource is a File:
- And the
destination
does not exist thenIO.copyFile(Path, Path)
is used. - And the
destination
is a File thenIO.copyFile(Path, Path)
is used. - And the
destination
is a Directory then a newPath
reference is created in the destination with the same filename as this Resource, which is used viaIO.copyFile(Path, Path)
.
If this Resource is a Directory:
- And the
destination
does not exist then the destination is created as a directory viaFiles.createDirectories(Path, FileAttribute[])
before theIO.copyDir(Path, Path)
method is used. - And the
destination
is a File then this results in anIllegalArgumentException
. - And the
destination
is a Directory then all files in this Resource directory tree are copied to thedestination
, usingIO.copyFile(Path, Path)
maintaining the same directory structure.
If this Resource is not backed by a
Path
, useResource.newInputStream()
:- And the
destination
does not exist, copyInputStream
to thedestination
as a new file. - And the
destination
is a File, copyInputStream
to the existingdestination
file. - And the
destination
is a Directory, copyInputStream
to a newdestination
file in the destination directory based on this the result ofResource.getFileName()
as the filename.
- Overrides:
copyTo
in classResource
- Parameters:
destination
- the destination file or directory to use (created if it does not exist).- Throws:
IOException
- if unable to copy the resource
- And the
-
equals
-
hashCode
public int hashCode() -
isAlias
public boolean isAlias() -
getRealURI
Description copied from class:Resource
The real URI of the resource.
If this Resource is an alias, (
Resource.isAlias()
), this URI will be different fromResource.getURI()
, and will point to the real name/location of the Resource.- Overrides:
getRealURI
in classResource
- Returns:
- The real URI location of this resource.
-
toString
-
contains
Description copied from class:Resource
Return true if this resource deeply contains the other Resource. This resource must be a directory or a jar file or any form of resource capable of containing other resources. -
getPathTo
Description copied from class:Resource
Get the relative path from this Resource to a possibly contained resource. -
isSameFile
- Overrides:
isSameFile
in classResource
-