Package org.apache.sshd.sftp.server
Class Handle
- java.lang.Object
-
- org.apache.sshd.sftp.server.Handle
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.Channel,AttributeRepository,AttributeStore
- Direct Known Subclasses:
DirectoryHandle,FileHandle
public abstract class Handle extends java.lang.Object implements java.nio.channels.Channel, AttributeStore
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.sshd.common.AttributeRepository
AttributeRepository.AttributeKey<T>
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<AttributeRepository.AttributeKey<?>,java.lang.Object>attributesprivate java.util.concurrent.atomic.AtomicBooleanclosedprivate java.nio.file.Pathfileprivate java.lang.Stringhandleprivate SftpSubsystemsftpSubsystem
-
Constructor Summary
Constructors Modifier Constructor Description protectedHandle(SftpSubsystem subsystem, java.nio.file.Path file, java.lang.String handle)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<AttributeRepository.AttributeKey<?>>attributeKeys()voidclearAttributes()Removes all currently stored user-defined attributesvoidclose()<T> TcomputeAttributeIfAbsent(AttributeRepository.AttributeKey<T> key, java.util.function.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> TgetAttribute(AttributeRepository.AttributeKey<T> key)Returns the value of the user-defined attribute.intgetAttributesCount()java.nio.file.PathgetFile()java.lang.StringgetFileHandle()protected SftpSubsystemgetSubsystem()booleanisOpen()<T> TremoveAttribute(AttributeRepository.AttributeKey<T> key)Removes the user-defined attribute<T> TsetAttribute(AttributeRepository.AttributeKey<T> key, T value)Sets a user-defined attribute.protected voidsignalHandleOpen()protected voidsignalHandleOpening()java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.AttributeRepository
resolveAttribute
-
-
-
-
Field Detail
-
sftpSubsystem
private final SftpSubsystem sftpSubsystem
-
closed
private final java.util.concurrent.atomic.AtomicBoolean closed
-
file
private final java.nio.file.Path file
-
handle
private final java.lang.String handle
-
attributes
private final java.util.Map<AttributeRepository.AttributeKey<?>,java.lang.Object> attributes
-
-
Constructor Detail
-
Handle
protected Handle(SftpSubsystem subsystem, java.nio.file.Path file, java.lang.String handle)
-
-
Method Detail
-
getSubsystem
protected SftpSubsystem getSubsystem()
-
signalHandleOpening
protected void signalHandleOpening() throws java.io.IOException- Throws:
java.io.IOException
-
signalHandleOpen
protected void signalHandleOpen() throws java.io.IOException- Throws:
java.io.IOException
-
getFile
public java.nio.file.Path getFile()
-
getFileHandle
public java.lang.String getFileHandle()
-
getAttributesCount
public int getAttributesCount()
- Specified by:
getAttributesCountin interfaceAttributeRepository- Returns:
- Current number of user-defined attributes stored in the repository
-
getAttribute
public <T> T getAttribute(AttributeRepository.AttributeKey<T> key)
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
public java.util.Collection<AttributeRepository.AttributeKey<?>> 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, java.util.function.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
public <T> T setAttribute(AttributeRepository.AttributeKey<T> key, T value)
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
public <T> T removeAttribute(AttributeRepository.AttributeKey<T> key)
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()
- Specified by:
isOpenin interfacejava.nio.channels.Channel
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.nio.channels.Channel- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-