Class PathStrategy

    • Field Detail

      • dir

        protected final Path dir
      • SAFE

        protected static final Pattern SAFE
      • HEX

        protected static final char[] HEX
    • Constructor Detail

      • PathStrategy

        public PathStrategy​(Path dir)
    • Method Detail

      • safePath

        protected String safePath​(String key)
        Converts a key to a safe path.

        Different keys always map to different safe paths (no collision).

        Parameters:
        key - the key
        Returns:
        the safe path
        Since:
        11.5
      • safePathInverse

        protected String safePathInverse​(String path)
        Parameters:
        path - the safe path
        Returns:
        the key, or null if the safe path is invalid
        Since:
        2021.8
      • createTempFile

        public Path createTempFile()
        Creates a temporary file in a location suitable for efficient move to the final path for any key.
        Returns:
        the temporary file
      • isTempFile

        public boolean isTempFile​(Path path)
        Checks if the given file is a temporary file
        Parameters:
        path - the file
        Returns:
        true if the file is a temporary file
        Since:
        11.5
      • getPathForKey

        public abstract Path getPathForKey​(String key)
        Gets the storage path for a given key.
        Parameters:
        key - the key
        Returns:
        the file for this key
      • getKeyForPath

        public String getKeyForPath​(String path)
        Gets the key for a given storage path.
        Parameters:
        path - the path
        Returns:
        the key
      • atomicMove

        public static void atomicMove​(Path source,
                                      Path dest)
                               throws IOException
        Does an atomic move from source to dest.
        Parameters:
        source - the source
        dest - the destination
        Throws:
        IOException
      • atomicCopy

        public static void atomicCopy​(Path source,
                                      Path dest)
                               throws IOException
        Does an atomic copy from source to dest.
        Parameters:
        source - the source
        dest - the destination
        Throws:
        IOException
        Since:
        11.5