Constructor and Description |
---|
SftpPathImpl(SftpFileSystem fileSystem,
String root,
List<String> names) |
Modifier and Type | Method and Description |
---|---|
protected void |
cacheAttributes(boolean doCache)
SftpPath instances can cache SFTP SftpClient.Attributes . |
void |
cacheAttributes(SftpClient.Attributes attributes)
Sets the cached attributes to the argument if this
SftpPath instance is currently caching attributes. |
SftpClient.Attributes |
getAttributes()
Retrieves the cached
SftpClient.Attributes of this SftpPath , if it has any. |
void |
setAttributes(SftpClient.Attributes attributes)
Unconditionally set the cached attributes, whether or not this instance's attribute cache is enabled.
|
<T> T |
withAttributeCache(IOFunction<Path,T> operation)
Performs the given operation with attribute caching.
|
static <T> T |
withAttributeCache(Path path,
IOFunction<Path,T> operation)
Performs the given operation with attribute caching, if the given
Path can cache attributes, otherwise
simply executes the operation. |
toRealPath
asString, asT, calculatedHashCode, checkPath, compare, compareTo, create, create, create, endsWith, endsWith, endsWith, equals, getFileName, getFileSystem, getName, getNameCount, getParent, getRoot, hashCode, isAbsolute, isNormal, iterator, normalize, register, register, relativize, resolve, resolve, resolveSibling, resolveSibling, startsWith, startsWith, startsWith, subpath, toAbsolutePath, toFile, toString, toUri
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
forEach, spliterator
public SftpPathImpl(SftpFileSystem fileSystem, String root, List<String> names)
protected void cacheAttributes(boolean doCache)
SftpPath
instances can cache SFTP SftpClient.Attributes
. Caching can be enabled by passing
true
. If the SftpPath
instance is already caching attributes, a counter is increased only. To
disable caching, pass false
, which decreases the counter. The cache is cleared when the counter reaches
zero again.
Each call of cacheAttributes(true)
must be matched by a call to cacheAttributes(false)
. Such call
pairs can be nested; caching is enabled for the duration of the outermost such pair. The outermost call passing
true
clears any possibly already cached attributes so that the next attempt to read remote attributes
will fetch them anew.
Client code should use withAttributeCache(Path, IOFunction)
, which ensures the above condition.
doCache
- whether to start caching (increasing the cache level) or to stop caching (decreasing the cache
level)withAttributeCache(Path, IOFunction)
public void cacheAttributes(SftpClient.Attributes attributes)
SftpPath
instance is currently caching attributes.
Otherwise a no-op.attributes
- the SftpClient.Attributes
to cachepublic void setAttributes(SftpClient.Attributes attributes)
attributes
- the SftpClient.Attributes
to cachepublic SftpClient.Attributes getAttributes()
SftpPath
SftpClient.Attributes
of this SftpPath
, if it has any.getAttributes
in class SftpPath
SftpClient.Attributes
or null
if there are none cachedpublic <T> T withAttributeCache(IOFunction<Path,T> operation) throws IOException
SftpClient.Attributes
are fetched by the
operation, they will be cached and subsequently these cached attributes will be re-used for this SftpPath
instance throughout the operation. Calls to withAttributeCache(IOFunction)
may be nested. The cache is
cleared at the start and at the end of the outermost invocation.T
- result type of the operation
operation
- to perform; may return null
if it has no resultoperation
IOException
- if thrown by the operation
public static <T> T withAttributeCache(Path path, IOFunction<Path,T> operation) throws IOException
Path
can cache attributes, otherwise
simply executes the operation.T
- result type of the operation
path
- Path
to operate onoperation
- to perform; may return null
if it has no resultoperation
IOException
- if thrown by the operation
withAttributeCache(IOFunction)
Copyright © 2008–2024 The Apache Software Foundation. All rights reserved.