public abstract class Handle extends java.lang.Object implements java.nio.channels.Channel, AttributeStore
AttributeRepository.AttributeKey<T>
Modifier and Type | Field and 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 |
Modifier | Constructor and Description |
---|---|
protected |
Handle(SftpSubsystem subsystem,
java.nio.file.Path file,
java.lang.String handle) |
Modifier and Type | Method and Description |
---|---|
java.util.Collection<AttributeRepository.AttributeKey<?>> |
attributeKeys() |
void |
clearAttributes()
Removes all currently stored user-defined attributes
|
void |
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 to
null ), attempts to compute
its value using the given mapping function and enters it into this map unless null . |
<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() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
ofAttributesMap, ofKeyValuePair, resolveAttribute
private final SftpSubsystem sftpSubsystem
private final java.util.concurrent.atomic.AtomicBoolean closed
private final java.nio.file.Path file
private final java.lang.String handle
private final java.util.Map<AttributeRepository.AttributeKey<?>,java.lang.Object> attributes
protected Handle(SftpSubsystem subsystem, java.nio.file.Path file, java.lang.String handle)
protected SftpSubsystem getSubsystem()
protected void signalHandleOpening() throws java.io.IOException
java.io.IOException
protected void signalHandleOpen() throws java.io.IOException
java.io.IOException
public java.nio.file.Path getFile()
public java.lang.String getFileHandle()
public int getAttributesCount()
getAttributesCount
in interface AttributeRepository
public <T> T getAttribute(AttributeRepository.AttributeKey<T> key)
AttributeRepository
getAttribute
in interface AttributeRepository
T
- The generic attribute typekey
- The key of the attribute; must not be null
.null
if there is no value associated with the specified keypublic java.util.Collection<AttributeRepository.AttributeKey<?>> attributeKeys()
attributeKeys
in interface AttributeRepository
Collection
snapshot of all the currently registered attributes in the repositorypublic <T> T computeAttributeIfAbsent(AttributeRepository.AttributeKey<T> key, java.util.function.Function<? super AttributeRepository.AttributeKey<T>,? extends T> resolver)
AttributeStore
null
), attempts to compute
its value using the given mapping function and enters it into this map unless null
.computeAttributeIfAbsent
in interface AttributeStore
T
- The generic attribute typekey
- The key of the attribute; must not be null
.resolver
- The (never null
) mapping function to use if value not already mapped. If returns
null
then value is not mapped to the provided key.null
if value not mapped and resolver did not return a
non-null
value for itpublic <T> T setAttribute(AttributeRepository.AttributeKey<T> key, T value)
AttributeStore
setAttribute
in interface AttributeStore
T
- The generic attribute typekey
- The key of the attribute; must not be null
.value
- The value of the attribute; must not be null
.null
if it is new.public <T> T removeAttribute(AttributeRepository.AttributeKey<T> key)
AttributeStore
removeAttribute
in interface AttributeStore
T
- The generic attribute typekey
- The key of the attribute; must not be null
.null
if no previous valuepublic void clearAttributes()
AttributeStore
clearAttributes
in interface AttributeStore
public boolean isOpen()
isOpen
in interface java.nio.channels.Channel
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface java.nio.channels.Channel
java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object