Package org.forgerock.openig.text
Class SeparatedValuesFile
- java.lang.Object
-
- org.forgerock.openig.text.SeparatedValuesFile
-
-
Constructor Summary
Constructors Constructor Description SeparatedValuesFile(File file)Builds a new SeparatedValuesFile reading the givenfileusing a theSeparators.COMMAseparator specification andUTF-8charset.SeparatedValuesFile(File file, Charset charset)Builds a new SeparatedValuesFile reading the givenfileusing a theSeparators.COMMAseparator specification.SeparatedValuesFile(File file, Charset charset, Separator separator)Builds a new SeparatedValuesFile reading the givenfile.SeparatedValuesFile(File file, Charset charset, Separator separator, boolean header)Builds a new SeparatedValuesFile reading the givenfile.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<String>getFields()Returns the explicit field keys in the order they appear in a record, overriding any existing field header, or empty to use field header.Map<String,String>getRecord(String key, String value)Returns a record from the file where the specified key is equal to the specified value.
-
-
-
Constructor Detail
-
SeparatedValuesFile
public SeparatedValuesFile(File file)
Builds a new SeparatedValuesFile reading the givenfileusing a theSeparators.COMMAseparator specification andUTF-8charset. This constructor consider the file has a header line.It is equivalent to call:
new SeparatedValuesFile(file, "UTF-8");- Parameters:
file- file to read from- See Also:
SeparatedValuesFile(File, Charset)
-
SeparatedValuesFile
public SeparatedValuesFile(File file, Charset charset)
Builds a new SeparatedValuesFile reading the givenfileusing a theSeparators.COMMAseparator specification. This constructor consider the file has a header line.It is equivalent to call:
new SeparatedValuesFile(file, charset, Separators.COMMA.getSeparator());- Parameters:
file- file to read fromcharset-Charsetof the file (non-null)- See Also:
SeparatedValuesFile(File, Charset, Separator)
-
SeparatedValuesFile
public SeparatedValuesFile(File file, Charset charset, Separator separator)
Builds a new SeparatedValuesFile reading the givenfile. This constructor consider the file has a header line.It is equivalent to call:
new SeparatedValuesFile(file, charset, separator, true);- Parameters:
file- file to read fromcharset-Charsetof the file (non-null)separator- separator specification- See Also:
SeparatedValuesFile(File, Charset, Separator, boolean)
-
SeparatedValuesFile
public SeparatedValuesFile(File file, Charset charset, Separator separator, boolean header)
Builds a new SeparatedValuesFile reading the givenfile.- Parameters:
file- file to read fromcharset-Charsetof the file (non-null)separator- separator specificationheader- does the file has a header first line ?
-
-
Method Detail
-
getFields
public List<String> getFields()
Returns the explicit field keys in the order they appear in a record, overriding any existing field header, or empty to use field header.- Returns:
- the explicit field keys in the order they appear in a record
-
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 recordvalue- the value that the key should have to find a matching record.- Returns:
- the record with the matching value, or
nullif no such record could be found. - Throws:
IOException- if an I/O exception occurs.
-
-