Class Handle

    • Field Detail

      • closed

        private final java.util.concurrent.atomic.AtomicBoolean closed
      • file

        private final java.nio.file.Path file
      • handle

        private final java.lang.String handle
    • Constructor Detail

      • Handle

        protected Handle​(SftpSubsystem subsystem,
                         java.nio.file.Path file,
                         java.lang.String handle)
    • Method Detail

      • 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()
        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:
        getAttributesCount in interface AttributeRepository
        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 interface AttributeRepository
        Type Parameters:
        T - The generic attribute type
        Parameters:
        key - The key of the attribute; must not be null.
        Returns:
        null if there is no value associated with the specified key
      • 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 to null), attempts to compute its value using the given mapping function and enters it into this map unless null.
        Specified by:
        computeAttributeIfAbsent in interface AttributeStore
        Type Parameters:
        T - The generic attribute type
        Parameters:
        key - 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.
        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 interface AttributeStore
        Type Parameters:
        T - The generic attribute type
        Parameters:
        key - The key of the attribute; must not be null.
        value - The value of the attribute; must not be null.
        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 interface AttributeStore
        Type Parameters:
        T - The generic attribute type
        Parameters:
        key - The key of the attribute; must not be null.
        Returns:
        The removed value; null if no previous value
      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in interface java.nio.channels.Channel
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.nio.channels.Channel
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • safe

        protected static java.lang.String safe​(java.lang.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 - to convert
        Returns:
        the printable handle string