Class LogicalPathMappers

java.lang.Object
io.ocfl.core.path.mapper.LogicalPathMappers

public final class LogicalPathMappers extends Object
This class defines common LogicalPathMapper implementations.
  • Method Details

    • directMapper

      public static LogicalPathMapper directMapper()
      Creates a LogicalPathMapper that directly maps logical paths to content paths, making no changes.
      Returns:
      mapper
    • percentEncodingWindowsMapper

      public static LogicalPathMapper percentEncodingWindowsMapper()
      Creates a percent-encoding mapper that encodes the following characters that are problematic for Windows:
      • ASCII characters codes: x0-x1f
      • ASCII characters codes: x7f-xa0
      • Characters: <>:"\|?*

      This should produce generally safe content paths, but they are not guaranteed safe.

      Returns:
      mapper
    • percentEncodingLinuxMapper

      public static LogicalPathMapper percentEncodingLinuxMapper()
      Creates a percent-encoding that encodes the following characters:
      • ASCII characters codes: x0-x1f
      • ASCII characters codes: x7f-xa0
      • Characters:

      Linux is extremely permissive when it comes to the characters that are allowed in filenames. Some of the characters encoded here are in fact legal. However, it is often undesirable for them to appear in filenames.

      Returns:
      mapper
    • percentEncodingCloudMapper

      public static LogicalPathMapper percentEncodingCloudMapper()
      Creates a percent-encoding that encodes the following characters that are problematic for some cloud storage platforms:
      • ASCII characters codes: x0-x1f
      • ASCII characters codes: x7f-xa0
      • Characters: \#[]*?

      This should produce generally safe content paths, but they are not guaranteed safe.

      Returns:
      mapper
    • percentEncodingAllMapper

      public static LogicalPathMapper percentEncodingAllMapper()
      Creates a percent-encoding that encodes the following characters that are generally problematic across Windows, linux, and cloud platforms:
      • ASCII characters codes: x0-x1f
      • ASCII characters codes: x7f-xa0
      • Characters: <>:"\|?* #[]

      This should produce generally safe content paths, but they are not guaranteed safe.

      Returns:
      mapper
    • conservativePercentEncodingMapper

      public static LogicalPathMapper conservativePercentEncodingMapper()
      Creates a percent-encoding that percent-encodes every character except: [a-zA-Z0-9_-].

      This is an extremely conservative mapper that will produce content paths without problematic characters. However, it will also greatly inflate the size of the paths, potentially making them longer than the filesystem's filename size limit.

      Returns:
      mapper