Top Description Fields Constructors Methods
org.apache.sshd.sftp.client.impl

public Class SftpPathImpl

extends SftpPath
implements WithFileAttributeCache
Class Inheritance
All Implemented Interfaces
org.apache.sshd.sftp.client.fs.WithFileAttributeCache, org.apache.sshd.sftp.client.fs.WithFileAttributes
Imports
java.io.IOException, java.nio.file.Path, java.util.List, org.apache.sshd.common.util.io.functors.IOFunction, org.apache.sshd.sftp.client.SftpClient, org.apache.sshd.sftp.client.fs.SftpFileSystem, .SftpPath, .WithFileAttributeCache

An SftpPath that can cache SftpClient.Attributes.

Field Summary

Modifier and TypeField and Description
private SftpClient.Attributes
private int

Constructor Summary

AccessConstructor and Description
public
SftpPathImpl(SftpFileSystem fileSystem, String root, List<String> names)

Method Summary

Modifier and TypeMethod and Description
protected void
cacheAttributes(boolean
whether to start caching (increasing the cache level) or to stop caching (decreasing the cache level)
doCache
)

SftpPath instances can cache SFTP SftpClient.Attributes.

public SftpClient.Attributes
public void
public <T> T
withAttributeCache(IOFunction<Path, T>
to perform; may return null if it has no result
operation
)

Implements org.apache.sshd.sftp.client.fs.WithFileAttributeCache.withAttributeCache.

Performs the given operation with attribute caching.

Inherited from org.apache.sshd.sftp.client.fs.SftpPath:
toRealPath

Field Detail

attributesback to summary
private SftpClient.Attributes attributes
cachingLevelback to summary
private int cachingLevel

Constructor Detail

SftpPathImplback to summary
public SftpPathImpl(SftpFileSystem fileSystem, String root, List<String> names)

Method Detail

cacheAttributesback to summary
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.

Parameters
doCache:boolean

whether to start caching (increasing the cache level) or to stop caching (decreasing the cache level)

See Also
withAttributeCache(Path, IOFunction)
getAttributesback to summary
public SftpClient.Attributes getAttributes()

Overrides org.apache.sshd.sftp.client.fs.SftpPath.getAttributes.

Implements org.apache.sshd.sftp.client.fs.WithFileAttributes.getAttributes.

Doc from org.apache.sshd.sftp.client.fs.WithFileAttributes.getAttributes.

Retrieves the Attributes of this object, if it has any.

Returns:SftpClient.Attributes

the Attributes or null if there are none

Annotations
@Override
setAttributesback to summary
public void setAttributes(SftpClient.Attributes attributes)

Implements org.apache.sshd.sftp.client.fs.WithFileAttributeCache.setAttributes.

Doc from org.apache.sshd.sftp.client.fs.WithFileAttributeCache.setAttributes.

Sets the attributes.

Parameters
attributes:SftpClient.Attributes

SftpClient.Attributes to set

Annotations
@Override
withAttributeCacheback to summary
public <T> T withAttributeCache(IOFunction<Path, T> operation) throws IOException

Implements org.apache.sshd.sftp.client.fs.WithFileAttributeCache.withAttributeCache.

Doc from org.apache.sshd.sftp.client.fs.WithFileAttributeCache.withAttributeCache.

Performs the given operation with attribute caching. If 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.

Parameters
<T>
result type of the operation
operation:IOFunction<Path, T>

to perform; may return null if it has no result

Returns:T

the result of the operation

Annotations
@Override
Exceptions
IOException:
if thrown by the operation