Class SeparatedValuesFile

java.lang.Object
org.forgerock.openig.text.SeparatedValuesFile

public class SeparatedValuesFile extends Object
Allows records to be retrieved from a delimiter-separated file using key and value. Once constructed, an instance of this class is thread-safe, meaning the object can be long-lived, and multiple concurrent calls to getRecord is fully supported.
  • Constructor Details

    • SeparatedValuesFile

      public SeparatedValuesFile(File file, Charset charset, Separator separator, boolean header)
      Builds a new SeparatedValuesFile reading the given file.
      Parameters:
      file - file to read from
      charset - Charset of the file (non-null)
      separator - separator specification
      header - does the file has a header first line ?
  • Method Details

    • setFields

      public void setFields(List<String> fields)
      Set the explicit field keys in the order they appear in a record, overriding any existing field header, or empty to use field header.
      Parameters:
      fields - the fields to set.
    • getRecord

      public Map<String,String> getRecord(String key, String value) throws IOException
      Returns a record from the file where the specified key is equal to the specified value.
      Parameters:
      key - the key to use to lookup the record
      value - the value that the key should have to find a matching record.
      Returns:
      the record with the matching value, or null if no such record could be found.
      Throws:
      IOException - if an I/O exception occurs.