Class PathBiMap

java.lang.Object
io.ocfl.core.model.PathBiMap

public class PathBiMap extends Object
BiDirection map implementation that focuses on OCFL structures. FileIds are digest values and are case insensitive. A single fileId can map to many paths, but a single path can only map to one fileId.
  • Constructor Details

    • PathBiMap

      public PathBiMap()
  • Method Details

    • fromFileIdMap

      public static PathBiMap fromFileIdMap(Map<String,Set<String>> map)
      Constructs a new PathBiMap from an existing map of fileIds to paths.
      Parameters:
      map - fileId => paths map
      Returns:
      PathBiMap
    • containsFileId

      public boolean containsFileId(String fileId)
      Indicates if the specified fileId is in the map
      Parameters:
      fileId - fileId
      Returns:
      true if it's in the map
    • containsPath

      public boolean containsPath(String path)
      Indicates if the specified path is in the map
      Parameters:
      path - path
      Returns:
      true if it's in the map
    • put

      public void put(String fileId, String path)
      Adds a new fileId => path mapping
      Parameters:
      fileId - fileId
      path - path
    • getPaths

      public Set<String> getPaths(String fileId)
      Returns all of the paths associated to the fileId, or an empty set.
      Parameters:
      fileId - fileId
      Returns:
      set of paths
    • getFileId

      public String getFileId(String path)
      Returns the fileId associated to the path or null
      Parameters:
      path - path
      Returns:
      fileId or null
    • removePath

      public String removePath(String path)
      Removes the path from the map. If it is the only path associated to a fileId, then the fileId is also removed.
      Parameters:
      path - the path to remove
      Returns:
      the fileId of the path that was removed or null
    • removeFileId

      public Set<String> removeFileId(String fileId)
      Removes a fileId from the map. All of its paths are also removed.
      Parameters:
      fileId - the fileId to remove
      Returns:
      the associated paths
    • getFileIdToPaths

      public Map<String,Set<String>> getFileIdToPaths()
      Returns an immutable view of the PathBiMap, mapping fileIds to paths.
      Returns:
      immutable fileId => paths map
    • getPathToFileId

      public Map<String,String> getPathToFileId()
      Returns an immutable view of the PathBiMap, mapping paths to fileIds
      Returns:
      immutable path => fileId map
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object