Class MCRMetaISO8601Date

java.lang.Object
org.mycore.datamodel.metadata.MCRMetaDefault
org.mycore.datamodel.metadata.MCRMetaISO8601Date
All Implemented Interfaces:
Cloneable, MCRMetaInterface

public final class MCRMetaISO8601Date extends MCRMetaDefault
provides support for a restricted range of formats, all of which are valid ISO 8601 dates and times. The range of supported formats is exactly the same range that is suggested by the W3C datetime profile in its version from 1997-09-15.
Since:
1.3
Version:
$Revision$ $Date$
Author:
Thomas Scheffler (yagee)
  • Constructor Details

  • Method Details

    • createXML

      public Element createXML() throws MCRException
      Description copied from class: MCRMetaDefault
      This abstract method create a XML stream for all data in this class, defined by the MyCoRe XML MCRMeta... definition for the given subtag.
      Specified by:
      createXML in interface MCRMetaInterface
      Overrides:
      createXML in class MCRMetaDefault
      Returns:
      a JDOM Element with the XML MCRMeta... part
      Throws:
      MCRException - if the content of this class is not valid
    • createJSON

      public com.google.gson.JsonObject createJSON()
      Creates the JSON representation. Extends the MCRMetaDefault.createJSON() method with the following data.
         {
           date: "2016-02-08",
           format: "YYYY-MM-DD"
         }
       
      Specified by:
      createJSON in interface MCRMetaInterface
      Overrides:
      createJSON in class MCRMetaDefault
      Returns:
      a GSON object containing the json data of the metadata part
    • setFromDOM

      public void setFromDOM(Element element)
      Description copied from class: MCRMetaDefault
      This method read the XML input stream part from a DOM part for the metadata of the document.
      Specified by:
      setFromDOM in interface MCRMetaInterface
      Overrides:
      setFromDOM in class MCRMetaDefault
      Parameters:
      element - a relevant DOM element for the metadata
    • getNs

      protected static Namespace getNs()
      returns the namespace of this element
      Returns:
      Returns the ns.
    • setDate

      public void setDate(String isoString)
      sets the date for this meta data object
      Parameters:
      isoString - Date in any form that is a valid W3C dateTime
    • getDate

      public Date getDate()
      returns the Date representing this element.
      Returns:
      a new Date instance of the time set in this element
    • setDate

      public void setDate(Date dt)
      sets the date for this meta data object
      Parameters:
      dt - Date object representing date String in Element
    • getISOString

      public String getISOString()
      returns a ISO 8601 conform String using the current set format.
      Returns:
      date in ISO 8601 format, or null if date is unset.
    • setFormat

      public void setFormat(String format)
      sets the input and output format. please use only the formats defined on the W3C Page, which are also exported as static fields by this class.
      Parameters:
      format - a format string that is valid conforming to xsd:duration schema type.
    • getFormat

      public String getFormat()
    • getMCRISO8601Date

      public MCRISO8601Date getMCRISO8601Date()
      Returns the internal date.
      Returns:
      the base date
    • debug

      public void debug()
      This method put debug data to the logger (for the debug mode).
      Specified by:
      debug in interface MCRMetaInterface
      Overrides:
      debug in class MCRMetaDefault
    • clone

      public MCRMetaISO8601Date clone()
      clone of this instance you will get a (deep) clone of this element
      Specified by:
      clone in interface MCRMetaInterface
      Overrides:
      clone in class MCRMetaDefault
      See Also:
    • validate

      public void validate() throws MCRException
      Validates this MCRMetaISO8601Date. This method throws an exception if:
      • the subtag is not null or empty
      • the lang value was supported
      • the inherited value is lower than zero
      • the isoDate or the temporal accessor is null
      Specified by:
      validate in interface MCRMetaInterface
      Overrides:
      validate in class MCRMetaDefault
      Throws:
      MCRException - the MCRMetaISO8601Date is invalid
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class MCRMetaDefault