Package org.forgerock.openig.text
Class SeparatedValuesFile
java.lang.Object
org.forgerock.openig.text.SeparatedValuesFile
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 Summary
ConstructorDescriptionSeparatedValuesFile
(File file) Builds a new SeparatedValuesFile reading the givenfile
using a theSeparators.COMMA
separator specification andUTF-8
charset.SeparatedValuesFile
(File file, Charset charset) Builds a new SeparatedValuesFile reading the givenfile
using a theSeparators.COMMA
separator 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
Modifier and TypeMethodDescriptionReturns the explicit field keys in the order they appear in a record, overriding any existing field header, or empty to use field header.Returns a record from the file where the specified key is equal to the specified value.
-
Constructor Details
-
SeparatedValuesFile
Builds a new SeparatedValuesFile reading the givenfile
using a theSeparators.COMMA
separator specification andUTF-8
charset. 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
Builds a new SeparatedValuesFile reading the givenfile
using a theSeparators.COMMA
separator 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
-Charset
of the file (non-null)- See Also:
-
SeparatedValuesFile
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
-Charset
of the file (non-null)separator
- separator specification- See Also:
-
SeparatedValuesFile
Builds a new SeparatedValuesFile reading the givenfile
.- Parameters:
file
- file to read fromcharset
-Charset
of the file (non-null)separator
- separator specificationheader
- does the file has a header first line ?
-
-
Method Details
-
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
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
null
if no such record could be found. - Throws:
IOException
- if an I/O exception occurs.
-