Package nl.knaw.dans.bagit.reader
Class BagitTextFileReader
java.lang.Object
nl.knaw.dans.bagit.reader.BagitTextFileReader
This class is responsible for reading and parsing bagit.txt files from the filesystem
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte[]private static final Stringprivate static final Stringprivate static final org.slf4j.Loggerprivate static final ResourceBundleprivate static final Version -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic VersionparseVersion(String version) readBagitTextFile(Path bagitFile) Read the bagit.txt file and return the version and encoding.private static voidthrowErrorIfByteOrderMarkIsPresent(Path bagitFile) (package private) static void
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
BOM
private static final byte[] BOM -
messages
-
VERSION_1_0
-
LINE1_REGEX
- See Also:
-
LINE2_REGEX
- See Also:
-
-
Constructor Details
-
BagitTextFileReader
private BagitTextFileReader()
-
-
Method Details
-
readBagitTextFile
public static AbstractMap.SimpleImmutableEntry<Version,Charset> readBagitTextFile(Path bagitFile) throws IOException, UnparsableVersionException, InvalidBagMetadataException, InvalidBagitFileFormatException Read the bagit.txt file and return the version and encoding.- Parameters:
bagitFile- the bagit.txt file- Returns:
- the bag
VersionandCharsetencoding of the tag files - Throws:
IOException- if there is a problem reading a file. The file MUST be in UTF-8 encoding.UnparsableVersionException- if there is a problem parsing the bagit version numberInvalidBagMetadataException- if the bagit.txt file does not conform to "key: value"InvalidBagitFileFormatException- if the bagit.txt file does not conform to the bagit spec
-
throwErrorIfByteOrderMarkIsPresent
private static void throwErrorIfByteOrderMarkIsPresent(Path bagitFile) throws IOException, InvalidBagitFileFormatException -
throwErrorIfLinesDoNotMatchStrict
static void throwErrorIfLinesDoNotMatchStrict(List<String> lines) throws InvalidBagitFileFormatException - Throws:
InvalidBagitFileFormatException
-
parseVersion
- Throws:
UnparsableVersionException
-