Class DCRecordWriter

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

public class DCRecordWriter extends Object
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 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)
      Add a metadata element with namespace "dc" to the record element
      Parameters:
      name -
      value -
    • getMetadataValue

      public String getMetadataValue(String name)
      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

      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()