Class FileLabelMap<T>

Object
org.anchoranalysis.plugin.image.task.labeller.FileLabelMap<T>
Type Parameters:
T - the type of the file identifier

public class FileLabelMap<T>
extends Object
A map that associates file identifiers with labels, typically loaded from a CSV file.
  • Method Details

    • readFromCSV

      public static FileLabelMap<String> readFromCSV​(Path csvPath, boolean quotedStrings) throws org.anchoranalysis.io.input.csv.CSVReaderException
      Reads a FileLabelMap from a CSV file.
      Parameters:
      csvPath - the Path to the CSV file
      quotedStrings - whether strings in the CSV are quoted
      Returns:
      a new FileLabelMap instance populated with data from the CSV
      Throws:
      org.anchoranalysis.io.input.csv.CSVReaderException - if there's an error reading the CSV file
    • add

      public void add​(T fileId, String label)
      Adds a new file identifier and label pair to the map.
      Parameters:
      fileId - the file identifier
      label - the label associated with the file identifier
    • get

      public String get​(T fileId)
      Gets the label associated with a file identifier.
      Parameters:
      fileId - the file identifier
      Returns:
      the label associated with the file identifier, or null if not found
    • labels

      public Set<String> labels()
      Gets a set of all unique labels in the map.
      Returns:
      a Set of all labels
    • entrySet

      public Set<Map.Entry<T,​String>> entrySet()
      Gets the entry set of the internal map.
      Returns:
      a Set of map entries containing file identifiers and labels