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 Summary
Modifier and Type Method Description voidadd(T fileId, String label)Adds a new file identifier and label pair to the map.Set<Map.Entry<T,String>>entrySet()Gets the entry set of the internal map.Stringget(T fileId)Gets the label associated with a file identifier.Set<String>labels()Gets a set of all unique labels in the map.static FileLabelMap<String>readFromCSV(Path csvPath, boolean quotedStrings)Reads aFileLabelMapfrom a CSV file.
-
Method Details
-
readFromCSV
public static FileLabelMap<String> readFromCSV(Path csvPath, boolean quotedStrings) throws org.anchoranalysis.io.input.csv.CSVReaderExceptionReads aFileLabelMapfrom a CSV file.- Parameters:
csvPath- thePathto the CSV filequotedStrings- whether strings in the CSV are quoted- Returns:
- a new
FileLabelMapinstance populated with data from the CSV - Throws:
org.anchoranalysis.io.input.csv.CSVReaderException- if there's an error reading the CSV file
-
add
Adds a new file identifier and label pair to the map.- Parameters:
fileId- the file identifierlabel- the label associated with the file identifier
-
get
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
Gets a set of all unique labels in the map.- Returns:
- a
Setof all labels
-
entrySet
Gets the entry set of the internal map.- Returns:
- a
Setof map entries containing file identifiers and labels
-