Class DCRecordWriter

java.lang.Object
io.goobi.viewer.model.misc.DCRecordWriter

public class DCRecordWriter extends Object
Author:
Florian Alpers 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 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

      public void addDCMetadata(String name, String value)
      Adds a metadata element with namespace "dc" to the record element.
      Parameters:
      name - local name of the Dublin Core element (e.g. "title", "creator")
      value - text content to set for the element
    • getMetadataValue

      public String getMetadataValue(String name)
      Reads the value of the given metadata from the jdom document.
      Parameters:
      name - local name of the Dublin Core element to read
      Returns:
      Metadata value from the XML tree; null if none found
    • getDocument

      public org.jdom2.Document getDocument()
      Gets the base jdom2 document.
      Returns:
      the jdom2 document representing the record
    • write

      public void write(Path path) throws IOException
      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

      public String getAsString()