Package nl.knaw.dans.bagit.reader
Class KeyValueReader
java.lang.Object
nl.knaw.dans.bagit.reader.KeyValueReader
Convenience class for reading key value pairs from a file
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final String
private static final org.slf4j.Logger
private static final ResourceBundle
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static String[]
checkLineFormat
(String line, String splitRegex) private static void
mergeIndentedLine
(String line, List<AbstractMap.SimpleImmutableEntry<String, String>> keyValues) static List<AbstractMap.SimpleImmutableEntry<String,
String>> readKeyValuesFromFile
(Path file, String splitRegex, Charset charset) Generic method to read key value pairs from the bagit files, like bagit.txt or bag-info.txt
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
INDENTED_LINE_REGEX
- See Also:
-
messages
-
-
Constructor Details
-
KeyValueReader
private KeyValueReader()
-
-
Method Details
-
readKeyValuesFromFile
public static List<AbstractMap.SimpleImmutableEntry<String,String>> readKeyValuesFromFile(Path file, String splitRegex, Charset charset) throws IOException, InvalidBagMetadataException Generic method to read key value pairs from the bagit files, like bagit.txt or bag-info.txt- Parameters:
file
- the file to readsplitRegex
- how to split the key from the valuecharset
- the encoding of the file- Returns:
- a list of key value pairs
- Throws:
IOException
- if there was a problem reading the fileInvalidBagMetadataException
- if the file does not conform to pattern of key value
-
mergeIndentedLine
private static void mergeIndentedLine(String line, List<AbstractMap.SimpleImmutableEntry<String, String>> keyValues) -
checkLineFormat
private static String[] checkLineFormat(String line, String splitRegex) throws InvalidBagMetadataException - Throws:
InvalidBagMetadataException
-