Package io.goobi.viewer.model.misc
Class DCRecordWriter
java.lang.Object
io.goobi.viewer.model.misc.DCRecordWriter
- Author:
- florian Creates a xml document representing a simple Dublin Core record. Each instance of this class creates a single record which can be filled with metadata and eventually written to the file system
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addDCMetadata
(String name, String value) Add a metadata element with namespace "dc" to the record elementorg.jdom2.Document
Get the base jdom2 documentgetMetadataValue
(String name) Reads the value of the given metadata from the jdom documentvoid
Writes the created jdom document to the given path.
-
Field Details
-
NAMESPACE_DC
public static final org.jdom2.Namespace NAMESPACE_DC
-
-
Constructor Details
-
DCRecordWriter
public DCRecordWriter()Creates a new jdom document with an empty record element
-
-
Method Details
-
addDCMetadata
Add a metadata element with namespace "dc" to the record element- Parameters:
name
-value
-
-
getMetadataValue
Reads the value of the given metadata from the jdom document- Parameters:
name
-- Returns:
- Metadata value from the XML tree; null if none found
-
getDocument
public org.jdom2.Document getDocument()Get the base jdom2 document- Returns:
- the jdom2 document representing the record
-
write
Writes the created jdom document to the given path. If the path denotes a directory, a new file will be created within the directory with the filename being the "identifier" metadata value if it exists. Otherwise the "title" metadata value or the current timestamp if title doesn't exist either- Parameters:
path
- The path to the file (created if it doesn't exist, overwritten if it does) or the directory which should contain the file- Throws:
IOException
- if the parent directory of the given path doesn't exist, or writing the file fails for some other reason
-
getAsString
-