Class MetaDataFile
- java.lang.Object
-
- de.unirostock.sems.cbarchive.meta.MetaDataHolder
-
- de.unirostock.sems.cbarchive.meta.MetaDataFile
-
public class MetaDataFile extends MetaDataHolder
The Class MetaDataFile providing some static functions to read and write meta data files.- Author:
- Martin Scharm
-
-
Field Summary
-
Fields inherited from class de.unirostock.sems.cbarchive.meta.MetaDataHolder
descriptions
-
-
Constructor Summary
Constructors Constructor Description MetaDataFile()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
addAllMetaToEntry(Path file, ArchiveEntry entry)
Adds all descriptions of a file to a single entry, assuming all are about this file (ignoring the actual about!).String
getEntityPath()
Gets the path to this entity.static void
readFile(Path file, HashMap<String,ArchiveEntry> entries, CombineArchive archive, MetaDataHolder metaMetaHolder, List<Path> metaDataFiles, boolean continueOnError, List<String> errors)
static List<File>
writeFile(File baseDir, HashMap<String,ArchiveEntry> entries, CombineArchive archive, MetaDataHolder metaMetaHolder)
static List<File>
writeFiles(File baseDir, HashMap<String,ArchiveEntry> entries, CombineArchive archive, MetaDataHolder metaMetaHolder)
-
Methods inherited from class de.unirostock.sems.cbarchive.meta.MetaDataHolder
addDescription, addDescription, getDescriptions, removeDescription
-
-
-
-
Method Detail
-
readFile
public static void readFile(Path file, HashMap<String,ArchiveEntry> entries, CombineArchive archive, MetaDataHolder metaMetaHolder, List<Path> metaDataFiles, boolean continueOnError, List<String> errors) throws ParseException, org.jdom2.JDOMException, IOException, CombineArchiveException
Read a meta data file containing descriptions about thearchive
and/or itsentries
given inentries
.- Parameters:
file
- the file containing meta dataentries
- the entries available in the corresponding archivearchive
- the archive which contains this filemetaMetaHolder
- the meta data of meta datametaDataFiles
- the meta data file to evaluatecontinueOnError
- ignore errors and continue (as far as possible)errors
- the list of occurred errors- Throws:
ParseException
- the parse exceptionorg.jdom2.JDOMException
- the jDOM exceptionIOException
- Signals that an I/O exception has occurred.CombineArchiveException
- the combine archive exception
-
addAllMetaToEntry
public static int addAllMetaToEntry(Path file, ArchiveEntry entry) throws org.jdom2.JDOMException, IOException
Adds all descriptions of a file to a single entry, assuming all are about this file (ignoring the actual about!).- Parameters:
file
- the file containing the meta dataentry
- the entry in the archive- Returns:
- the number of descriptions added to
entry
- Throws:
org.jdom2.JDOMException
- the jDOM exceptionIOException
- Signals that an I/O exception has occurred.
-
writeFiles
public static List<File> writeFiles(File baseDir, HashMap<String,ArchiveEntry> entries, CombineArchive archive, MetaDataHolder metaMetaHolder) throws IOException, TransformerException
Write the meta data about thearchive
and itsentries
given inarchive
andentries
to a single meta data files.This method will create one meta data file per entry. Meta data files will be named
baseDir/metadata(-[-0-9a-f]+)?.rdf
. SeewriteFile(File,HashMap,CombineArchive,MetaDataHolder)
if you want to store all meta data in a single file.- Parameters:
baseDir
- the base directory to store the filesentries
- the archive entriesarchive
- the archive which will contain the filesmetaMetaHolder
- the meta data of meta data- Returns:
- the list of files that were created
- Throws:
IOException
- Signals that an I/O exception has occurred.TransformerException
- the transformer exception
-
writeFile
public static List<File> writeFile(File baseDir, HashMap<String,ArchiveEntry> entries, CombineArchive archive, MetaDataHolder metaMetaHolder) throws IOException, TransformerException
Write the meta data about thearchive
and itsentries
given inarchive
andentries
to a single meta data file.This method will create one meta data file for all description. Thus, the returned list of files will be of size one. The meta data file will be named
baseDir/metadata(-[-0-9a-f]+)?.rdf
. SeewriteFiles(File,HashMap,CombineArchive,MetaDataHolder)
if you want to store the meta data in a multiple files, one for each entry.- Parameters:
baseDir
- the base directory to store the fileentries
- the archive entriesarchive
- the archive which will contain the filesmetaMetaHolder
- the meta data of meta data- Returns:
- the list of files th the meta data of meta dataat were created (should be always of size one)
- Throws:
IOException
- Signals that an I/O exception has occurred.TransformerException
- the transformer exception
-
getEntityPath
public String getEntityPath()
Description copied from class:MetaDataHolder
Gets the path to this entity.- Specified by:
getEntityPath
in classMetaDataHolder
- Returns:
- the file path
-
-