Class MCRMetaHistoryDate

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

public class MCRMetaHistoryDate extends MCRMetaDefault
This class implements all methods for handling the MCRMetaHistoryDate part of a metadata object. It uses the GPL licensed ICU library of IBM.
Version:
$Revision$ $Date$
Author:
Juergen Vogler, Jens Kupferschmidt, Thomas Junge
See Also:
  • Field Details

    • MCRHISTORYDATE_MAX_TEXT

      public static final int MCRHISTORYDATE_MAX_TEXT
      The maximal length of 'text'
      See Also:
  • Constructor Details

    • MCRMetaHistoryDate

      public MCRMetaHistoryDate()
      This is the constructor.
      The language element was set to configured default. The text element is set to an empty string. The calendar is set to 'Gregorian Calendar'. The von value is set to MIN_JULIAN_DAY_NUMBER, the bis value is set to MAX_JULIAN_DAY_NUMBER;
    • MCRMetaHistoryDate

      public MCRMetaHistoryDate(String subtag, String type, int inherted) throws MCRException
      This is the constructor.
      The language element was set. If the value of default_lang is null, empty or false en was set. The subtag element was set to the value of subtag. If the value of subtag is null or empty an exception was thrown. The type element was set to the value of type, if it is null, an empty string was set to the type element.
      The text element is set to an empty string. The calendar is set to 'Gregorian Calendar'. The von value is set to MIN_JULIAN_DAY_NUMBER, the bis value is set to MAX_JULIAN_DAY_NUMBER;
      Parameters:
      subtag - the name of the subtag
      type - the optional type string
      inherted - a value >= 0
      Throws:
      MCRException - if the parameter values are invalid
  • Method Details

    • setText

      @Deprecated public final void setText(String text)
      Deprecated.
      This method set the text field for the default language. If data exists, it overwrites the value of text.
      Parameters:
      text - the text string for a date or range
    • setText

      public final void setText(String text, String lang)
      This method set the text field for the given language. If data exists, it overwrites the value of text.
      Parameters:
      text - the text string for a date or range
      lang - the language of the text in the ISO format
    • addText

      public final void addText(String text, String lang)
      This method add a MCRMetaHistoryDateTexts instance to the ArrayList of texts.
      Parameters:
      text - the text- String
      lang - the lang- String
    • getText

      This method return the MCRMetaHistoryDateTexts instance with the corresponding language.
      Parameters:
      lang - the language String in ISO format
      Returns:
      an instance of MCRMetaHistoryDateTexts or null
    • getText

      public final MCRMetaHistoryDate.MCRMetaHistoryDateText getText(int index)
      This method return the MCRMetaHistoryDateTexts instance of the indexed element of the ArrayList.
      Parameters:
      index - the index of ArryList texts
      Returns:
      an instance of MCRMetaHistoryDateTexts or null
    • getTexts

      This method read the ArryList texts
      Returns:
      an ArrayList of MCRMetaHistoryDateTexts instances
    • textSize

      public final int textSize()
      This method read the size of texts
      Returns:
      the size of the ArrayList of language dependence texts
    • setCalendar

      public final void setCalendar(String calstr)
      The method set the calendar String value.
      Parameters:
      calstr - the calendar as String, one of CALENDARS.
    • setCalendar

      public final void setCalendar(com.ibm.icu.util.Calendar calendar)
      The method set the calendar String value.
      Parameters:
      calendar - the date of the calendar.
    • setDefaultVon

      public final void setDefaultVon()
      The method set the von values to the default.
    • setDefaultBis

      public final void setDefaultBis()
      The method set the bis values to the default.
    • setVonDate

      public final void setVonDate(com.ibm.icu.util.Calendar calendar)
      This method set the von to the given date of a supported calendar.
      Parameters:
      calendar - the date of a ICU supported calendar.
    • setVonDate

      public final void setVonDate(String date, String calendar)
      This method set the von to the given date.
      Parameters:
      date - a date string
      calendar - the calendar as String, one of CALENDARS.
    • setBisDate

      public final void setBisDate(com.ibm.icu.util.Calendar calendar)
      This method set the bis to the given date of a supported calendar.
      Parameters:
      calendar - the date of a ICU supported calendar
    • setBisDate

      public final void setBisDate(String date, String calendar)
      This method set the bis to the given date.
      Parameters:
      date - a date string
      calendar - the calendar as String, one of CALENDARS.
    • getCalendar

      public final String getCalendar()
      This method get the 'calendar' text element.
      Returns:
      the calendar string
    • getVon

      public final com.ibm.icu.util.Calendar getVon()
      This method get the von element as ICU-Calendar.
      Returns:
      the date
    • getVonToString

      public final String getVonToString()
      This method return the von as string.
      Returns:
      the date
    • getIvon

      public final int getIvon()
      This method get the ivon element as Julian Day integer.
      Returns:
      the date
    • getBis

      public final com.ibm.icu.util.Calendar getBis()
      This method get the bis element as ICU-Calendar.
      Returns:
      the date
    • getBisToString

      public final String getBisToString()
      This method return the bis as string.
      Returns:
      the date
    • getIbis

      public final int getIbis()
      This method get the ibis element as Julian Day integer.
      Returns:
      the date
    • setFromDOM

      public void setFromDOM(Element element)
      This method reads 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 JDOM element for the metadata
    • createXML

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

      public void validate() throws MCRException
      Validates this MCRMetaHistoryDate. 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 number of texts is 0 (empty texts are delete)
      • von is null or bis is null or calendar is null
      Specified by:
      validate in interface MCRMetaInterface
      Overrides:
      validate in class MCRMetaDefault
      Throws:
      MCRException - the MCRMetaHistoryDate is invalid
    • clone

      public MCRMetaHistoryDate 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:
    • 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
    • equals

      public boolean equals(Object obj)
      This method compares this instance with a MCRMetaHistoryDate object
      Overrides:
      equals in class MCRMetaDefault