Class CombinedResource
java.lang.Object
org.eclipse.jetty.util.resource.Resource
org.eclipse.jetty.util.resource.CombinedResource
-
Method Summary
Modifier and TypeMethodDescriptionbooleanReturn true if this resource deeply contains the other Resource.voidCopy the Resource to the new destination file or directory.booleanbooleanexists()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.inthashCode()booleanisAlias()booleanReturn true if resource represents a directory of potential resources.booleanTrue if the resource is readable.booleanisSameFile(Path path) iterator()Return an Iterator of all Resource's referenced in this Resource.The time the resource was last modified.longlength()Length of the resource.list()List of contents of a directoryResource.Resolves a path against the resource collection.toString()Methods inherited from class Resource
dump, getAllResources, isContainedIn, newInputStream, newReadableByteChannelMethods inherited from interface Iterable
forEach, spliterator
-
Method Details
-
getResources
-
resolve
Resolves a path against the resource collection.- Specified by:
resolvein 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:ResourceEquivalent toFiles.exists(Path, LinkOption...)with the following parameters:Resource.getPath()andLinkOption.NOFOLLOW_LINKS. -
getPath
-
getName
-
getFileName
Description copied from class:ResourceThe file name of the resource.
This is the last segment of the path.
- Specified by:
getFileNamein 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
-
isDirectory
public boolean isDirectory()Description copied from class:ResourceReturn true if resource represents a directory of potential resources.- Specified by:
isDirectoryin classResource- Returns:
- true if the represented resource is a container/directory.
-
isReadable
public boolean isReadable()Description copied from class:ResourceTrue if the resource is readable.- Specified by:
isReadablein classResource- Returns:
- true if the represented resource exists, and can read from.
-
lastModified
Description copied from class:ResourceThe time the resource was last modified.- Overrides:
lastModifiedin classResource- Returns:
- the last modified time instant, or
Instant.EPOCHif unable to obtain last modified.
-
length
-
iterator
Description copied from class:ResourceReturn 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:ResourceList of contents of a directory
Resource.Ordering is
FileSystemdependent, so callers may wish to sort the return value to ensure deterministic behavior. -
copyTo
Description copied from class:ResourceCopy the Resource to the new destination file or directory.If this Resource is a File:
- And the
destinationdoes not exist thenIO.copyFile(Path, Path)is used. - And the
destinationis a File thenIO.copyFile(Path, Path)is used. - And the
destinationis a Directory then a newPathreference 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
destinationdoes not exist then the destination is created as a directory viaFiles.createDirectories(Path, FileAttribute[])before theIO.copyDir(Path, Path)method is used. - And the
destinationis a File then this results in anIllegalArgumentException. - And the
destinationis 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
destinationdoes not exist, copyInputStreamto thedestinationas a new file. - And the
destinationis a File, copyInputStreamto the existingdestinationfile. - And the
destinationis a Directory, copyInputStreamto a newdestinationfile in the destination directory based on this the result ofResource.getFileName()as the filename.
- Overrides:
copyToin 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
-
isAlias
-
getRealURI
Description copied from class:ResourceThe 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:
getRealURIin classResource- Returns:
- The real URI location of this resource.
-
toString
-
contains
Description copied from class:ResourceReturn 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:ResourceGet the relative path from this Resource to a possibly contained resource. -
isSameFile
- Overrides:
isSameFilein classResource
-