Package org.apache.sshd.sftp.server
Class Handle
java.lang.Object
org.apache.sshd.sftp.server.Handle
- All Implemented Interfaces:
Closeable,AutoCloseable,Channel,AttributeRepository,AttributeStore
- Direct Known Subclasses:
DirectoryHandle,FileHandle
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.sshd.common.AttributeRepository
AttributeRepository.AttributeKey<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Map<AttributeRepository.AttributeKey<?>, Object> private final AtomicBooleanprivate final Pathprivate final Stringprivate final SftpSubsystem -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHandle(SftpSubsystem subsystem, Path file, String handle) -
Method Summary
Modifier and TypeMethodDescriptionvoidRemoves all currently stored user-defined attributesvoidclose()<T> TcomputeAttributeIfAbsent(AttributeRepository.AttributeKey<T> key, Function<? super AttributeRepository.AttributeKey<T>, ? extends T> resolver) If the specified key is not already associated with a value (or is mapped tonull), attempts to compute its value using the given mapping function and enters it into this map unlessnull.<T> TReturns the value of the user-defined attribute.intgetFile()Retrieves the raw opaque file handle, which may contain characters not safe for printing.protected SftpSubsystembooleanisOpen()<T> TRemoves the user-defined attributeprotected static StringConverts 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.<T> TsetAttribute(AttributeRepository.AttributeKey<T> key, T value) Sets a user-defined attribute.protected voidprotected voidtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.sshd.common.AttributeRepository
resolveAttribute
-
Field Details
-
sftpSubsystem
-
closed
-
file
-
handle
-
attributes
-
-
Constructor Details
-
Handle
-
-
Method Details
-
getSubsystem
-
signalHandleOpening
- Throws:
IOException
-
signalHandleOpen
- Throws:
IOException
-
getFile
-
getFileHandle
Retrieves the raw opaque file handle, which may contain characters not safe for printing.- Returns:
- the raw file handle
-
getAttributesCount
public int getAttributesCount()- Specified by:
getAttributesCountin interfaceAttributeRepository- Returns:
- Current number of user-defined attributes stored in the repository
-
getAttribute
Description copied from interface:AttributeRepositoryReturns the value of the user-defined attribute.- Specified by:
getAttributein interfaceAttributeRepository- Type Parameters:
T- The generic attribute type- Parameters:
key- The key of the attribute; must not benull.- Returns:
nullif there is no value associated with the specified key
-
attributeKeys
- Specified by:
attributeKeysin interfaceAttributeRepository- Returns:
- A
Collectionsnapshot of all the currently registered attributes in the repository
-
computeAttributeIfAbsent
public <T> T computeAttributeIfAbsent(AttributeRepository.AttributeKey<T> key, Function<? super AttributeRepository.AttributeKey<T>, ? extends T> resolver) Description copied from interface:AttributeStoreIf the specified key is not already associated with a value (or is mapped tonull), attempts to compute its value using the given mapping function and enters it into this map unlessnull.- Specified by:
computeAttributeIfAbsentin interfaceAttributeStore- Type Parameters:
T- The generic attribute type- Parameters:
key- The key of the attribute; must not benull.resolver- The (nevernull) mapping function to use if value not already mapped. If returnsnullthen value is not mapped to the provided key.- Returns:
- The resolved value -
nullif value not mapped and resolver did not return a non-nullvalue for it
-
setAttribute
Description copied from interface:AttributeStoreSets a user-defined attribute.- Specified by:
setAttributein interfaceAttributeStore- Type Parameters:
T- The generic attribute type- Parameters:
key- The key of the attribute; must not benull.value- The value of the attribute; must not benull.- Returns:
- The old value of the attribute;
nullif it is new.
-
removeAttribute
Description copied from interface:AttributeStoreRemoves the user-defined attribute- Specified by:
removeAttributein interfaceAttributeStore- Type Parameters:
T- The generic attribute type- Parameters:
key- The key of the attribute; must not benull.- Returns:
- The removed value;
nullif no previous value
-
clearAttributes
public void clearAttributes()Description copied from interface:AttributeStoreRemoves all currently stored user-defined attributes- Specified by:
clearAttributesin interfaceAttributeStore
-
isOpen
public boolean isOpen() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Throws:
IOException
-
toString
-
safe
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- to convert- Returns:
- the printable handle string
-