Class Handle
- java.lang.Object
-
- org.apache.sshd.server.subsystem.sftp.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>
attributes
private java.util.concurrent.atomic.AtomicBoolean
closed
private java.nio.file.Path
file
private java.lang.String
handle
private SftpSubsystem
sftpSubsystem
-
Constructor Summary
Constructors Modifier Constructor Description protected
Handle(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()
void
clearAttributes()
Removes all currently stored user-defined attributesvoid
close()
<T> T
computeAttributeIfAbsent(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> T
getAttribute(AttributeRepository.AttributeKey<T> key)
Returns the value of the user-defined attribute.int
getAttributesCount()
java.nio.file.Path
getFile()
java.lang.String
getFileHandle()
protected SftpSubsystem
getSubsystem()
boolean
isOpen()
<T> T
removeAttribute(AttributeRepository.AttributeKey<T> key)
Removes the user-defined attribute<T> T
setAttribute(AttributeRepository.AttributeKey<T> key, T value)
Sets a user-defined attribute.protected void
signalHandleOpen()
protected void
signalHandleOpening()
java.lang.String
toString()
-
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:
getAttributesCount
in 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:AttributeRepository
Returns the value of the user-defined attribute.- Specified by:
getAttribute
in interfaceAttributeRepository
- Type Parameters:
T
- The generic attribute type- Parameters:
key
- The key of the attribute; must not benull
.- Returns:
null
if there is no value associated with the specified key
-
attributeKeys
public java.util.Collection<AttributeRepository.AttributeKey<?>> attributeKeys()
- Specified by:
attributeKeys
in interfaceAttributeRepository
- Returns:
- A
Collection
snapshot 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:AttributeStore
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
.- Specified by:
computeAttributeIfAbsent
in 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 returnsnull
then value is not mapped to the provided key.- Returns:
- The resolved value -
null
if value not mapped and resolver did not return a non-null
value for it
-
setAttribute
public <T> T setAttribute(AttributeRepository.AttributeKey<T> key, T value)
Description copied from interface:AttributeStore
Sets a user-defined attribute.- Specified by:
setAttribute
in 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;
null
if it is new.
-
removeAttribute
public <T> T removeAttribute(AttributeRepository.AttributeKey<T> key)
Description copied from interface:AttributeStore
Removes the user-defined attribute- Specified by:
removeAttribute
in interfaceAttributeStore
- Type Parameters:
T
- The generic attribute type- Parameters:
key
- The key of the attribute; must not benull
.- Returns:
- The removed value;
null
if no previous value
-
clearAttributes
public void clearAttributes()
Description copied from interface:AttributeStore
Removes all currently stored user-defined attributes- Specified by:
clearAttributes
in interfaceAttributeStore
-
isOpen
public boolean isOpen()
- Specified by:
isOpen
in interfacejava.nio.channels.Channel
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.nio.channels.Channel
- Specified by:
close
in interfacejava.io.Closeable
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-