Top Fields Constructors Methods
org.apache.sshd.sftp.server

public abstract Class Handle

extends Object
implements Channel, AttributeStore
Class Inheritance
All Implemented Interfaces
org.apache.sshd.common.AttributeStore, org.apache.sshd.common.AttributeRepository, java.nio.channels.Channel, java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
org.apache.sshd.sftp.server.DirectoryHandle, org.apache.sshd.sftp.server.FileHandle
Imports
java.io.IOException, java.nio.charset.StandardCharsets, java.nio.file.Path, java.util.Collection, .Collections, .HashSet, .Map, .Objects, java.util.concurrent.ConcurrentHashMap, java.util.concurrent.atomic.AtomicBoolean, java.util.function.Function, org.apache.sshd.common.AttributeRepository, .AttributeStore, org.apache.sshd.common.util.ValidateUtils, org.apache.sshd.common.util.buffer.BufferUtils, org.apache.sshd.server.session.ServerSession

Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
private final Map<AttributeRepository.AttributeKey<?>, Object>
private final AtomicBoolean
private final Path
private final String
private final SftpSubsystem

Constructor Summary

AccessConstructor and Description
protected
Handle(SftpSubsystem subsystem, Path file, String handle)

Method Summary

Modifier and TypeMethod and Description
public Collection<AttributeRepository.AttributeKey<?>>
public void
clearAttributes()

Implements org.apache.sshd.common.AttributeStore.clearAttributes.

Removes all currently stored user-defined attributes

public void
close()

Implements java.nio.channels.Channel.close.

Closes this channel.

public <T> T
computeAttributeIfAbsent(AttributeRepository.AttributeKey<T>
The key of the attribute; must not be null.
key
,
Function<? super AttributeRepository.AttributeKey<T>, ? extends T>
The (never null) mapping function to use if value not already mapped. If returns null then value is not mapped to the provided key.
resolver
)

Overrides default org.apache.sshd.common.AttributeStore.computeAttributeIfAbsent.

If the specified key is not already associated with a value (or is mapped to null), attempts to compute its value using the given mapping function and enters it into this map unless null.

public <T> T
getAttribute(AttributeRepository.AttributeKey<T>
The key of the attribute; must not be null.
key
)

Implements org.apache.sshd.common.AttributeRepository.getAttribute.

Returns the value of the user-defined attribute.

public int
public Path
public String

Returns:

the raw file handle
getFileHandle
()

Retrieves the raw opaque file handle, which may contain characters not safe for printing.

protected SftpSubsystem
public boolean
isOpen()

Implements java.nio.channels.Channel.isOpen.

Tells whether or not this channel is open.

public <T> T
removeAttribute(AttributeRepository.AttributeKey<T>
The key of the attribute; must not be null.
key
)

Implements org.apache.sshd.common.AttributeStore.removeAttribute.

Removes the user-defined attribute

protected static String

Returns:

the printable handle string
safe
(String
to convert
handle
)

Converts a file handle, which may contain non-printable characters, to a hex representation of its bytes, which is safe to write to logs or exception messages.

public <T> T
setAttribute(AttributeRepository.AttributeKey<T>
The key of the attribute; must not be null.
key
,
T
The value of the attribute; must not be null.
value
)

Implements org.apache.sshd.common.AttributeStore.setAttribute.

Sets a user-defined attribute.

protected void
protected void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

attributesback to summary
private final Map<AttributeRepository.AttributeKey<?>, Object> attributes
closedback to summary
private final AtomicBoolean closed
fileback to summary
private final Path file
handleback to summary
private final String handle
sftpSubsystemback to summary
private final SftpSubsystem sftpSubsystem

Constructor Detail

Handleback to summary
protected Handle(SftpSubsystem subsystem, Path file, String handle)

Method Detail

attributeKeysback to summary
public Collection<AttributeRepository.AttributeKey<?>> attributeKeys()

Implements org.apache.sshd.common.AttributeRepository.attributeKeys.

Returns:Collection<AttributeRepository.AttributeKey<?>>

Doc from org.apache.sshd.common.AttributeRepository.attributeKeys.

A Collection snapshot of all the currently registered attributes in the repository

Annotations
@Override
clearAttributesback to summary
public void clearAttributes()

Implements org.apache.sshd.common.AttributeStore.clearAttributes.

Doc from org.apache.sshd.common.AttributeStore.clearAttributes.

Removes all currently stored user-defined attributes

Annotations
@Override
closeback to summary
public void close() throws IOException

Implements java.nio.channels.Channel.close.

Doc from java.nio.channels.Channel.close.

Closes this channel.

After a channel is closed, any further attempt to invoke I/O operations upon it will cause a ClosedChannelException to be thrown.

If this channel is already closed then invoking this method has no effect.

This method may be invoked at any time. If some other thread has already invoked it, however, then another invocation will block until the first invocation is complete, after which it will return without effect.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs
computeAttributeIfAbsentback to summary
public <T> T computeAttributeIfAbsent(AttributeRepository.AttributeKey<T> key, Function<? super AttributeRepository.AttributeKey<T>, ? extends T> resolver)

Overrides default org.apache.sshd.common.AttributeStore.computeAttributeIfAbsent.

Doc from org.apache.sshd.common.AttributeStore.computeAttributeIfAbsent.

If the specified key is not already associated with a value (or is mapped to null), attempts to compute its value using the given mapping function and enters it into this map unless null.

Parameters
<T>
The generic attribute type
key:AttributeRepository.AttributeKey<T>

The key of the attribute; must not be null.

resolver:Function<? super AttributeRepository.AttributeKey<T>, ? extends T>

The (never null) mapping function to use if value not already mapped. If returns null then value is not mapped to the provided key.

Returns:T

The resolved value - null if value not mapped and resolver did not return a non-null value for it

Annotations
@Override
@SuppressWarnings:unchecked, rawtypes
getAttributeback to summary
public <T> T getAttribute(AttributeRepository.AttributeKey<T> key)

Implements org.apache.sshd.common.AttributeRepository.getAttribute.

Doc from org.apache.sshd.common.AttributeRepository.getAttribute.

Returns the value of the user-defined attribute.

Parameters
<T>
The generic attribute type
key:AttributeRepository.AttributeKey<T>

The key of the attribute; must not be null.

Returns:T

null if there is no value associated with the specified key

Annotations
@Override
@SuppressWarnings:unchecked
getAttributesCountback to summary
public int getAttributesCount()

Implements org.apache.sshd.common.AttributeRepository.getAttributesCount.

Returns:int

Doc from org.apache.sshd.common.AttributeRepository.getAttributesCount.

Current number of user-defined attributes stored in the repository

Annotations
@Override
getFileback to summary
public Path getFile()
getFileHandleback to summary
public String getFileHandle()

Retrieves the raw opaque file handle, which may contain characters not safe for printing.

Returns:String

the raw file handle

getSubsystemback to summary
protected SftpSubsystem getSubsystem()
isOpenback to summary
public boolean isOpen()

Implements java.nio.channels.Channel.isOpen.

Doc from java.nio.channels.Channel.isOpen.

Tells whether or not this channel is open.

Returns:boolean

true if, and only if, this channel is open

Annotations
@Override
removeAttributeback to summary
public <T> T removeAttribute(AttributeRepository.AttributeKey<T> key)

Implements org.apache.sshd.common.AttributeStore.removeAttribute.

Doc from org.apache.sshd.common.AttributeStore.removeAttribute.

Removes the user-defined attribute

Parameters
<T>
The generic attribute type
key:AttributeRepository.AttributeKey<T>

The key of the attribute; must not be null.

Returns:T

The removed value; null if no previous value

Annotations
@Override
@SuppressWarnings:unchecked
safeback to summary
protected static String safe(String handle)

Converts a file handle, which may contain non-printable characters, to a hex representation of its bytes, which is safe to write to logs or exception messages.

For historical reasons, Apache MINA sshd represents file handles as strings internally.

Parameters
handle:String

to convert

Returns:String

the printable handle string

setAttributeback to summary
public <T> T setAttribute(AttributeRepository.AttributeKey<T> key, T value)

Implements org.apache.sshd.common.AttributeStore.setAttribute.

Doc from org.apache.sshd.common.AttributeStore.setAttribute.

Sets a user-defined attribute.

Parameters
<T>
The generic attribute type
key:AttributeRepository.AttributeKey<T>

The key of the attribute; must not be null.

value:T

The value of the attribute; must not be null.

Returns:T

The old value of the attribute; null if it is new.

Annotations
@Override
@SuppressWarnings:unchecked
signalHandleOpenback to summary
protected void signalHandleOpen() throws IOException
signalHandleOpeningback to summary
protected void signalHandleOpening() throws IOException
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override