org.mycore.datamodel.metadata
Class MCRMetaHistoryDate

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

public class MCRMetaHistoryDate
extends MCRMetaDefault

This class implements all methods for handling with the MCRMetaHistoryDate part of a metadata object. It use the GPL licensed ICU library of IBM.

Version:
$Revision: 14335 $ $Date: 2008-11-06 07:40:09 +0100 (Do, 06 Nov 2008) $
Author:
Juergen Vogler, Jens Kupferschmidt, Thomas Junge
See Also:
http://www.icu-project.org/

Nested Class Summary
protected  class MCRMetaHistoryDate.MCRMetaHistoryDateText
          This class describes the structure of pair of language an text.
 
Field Summary
protected static Logger LOGGER
          Logger
static int MCRHISTORYDATE_MAX_TEXT
          The maximal length of 'text'
 
Fields inherited from class org.mycore.datamodel.metadata.MCRMetaDefault
datapart, DEFAULT_DATAPART, DEFAULT_INHERITED, DEFAULT_LANG_LENGTH, DEFAULT_LANGUAGE, DEFAULT_STRING_LENGTH, DEFAULT_TYPE_LENGTH, inherited, lang, NL, subtag, type
 
Constructor Summary
MCRMetaHistoryDate()
          This is the constructor.
MCRMetaHistoryDate(String set_datapart, String set_subtag, String default_lang, String set_type, int set_inherted)
          This is the constructor.
 
Method Summary
 void addText(String set_text, String set_lang)
          This method add a MCRMetaHistoryDateTexts instance to the ArrayList of texts.
 Object clone()
          This method make a clone of this class.
 Element createXML()
          This method creates a XML stream for all data in this class, defined by the MyCoRe XML MCRMetaHistoryDate definition for the given subtag.
 void debug()
          This method put debug data to the logger (for the debug mode).
 com.ibm.icu.util.Calendar getBis()
          This method get the bis element as ICU-Calendar.
 String getBisToGregorianString()
          This method return the bis as string.
 String getCalendar()
          This method get the 'calendar' text element.
 int getIbis()
          This method get the ibis element as Julian Day integer.
 int getIvon()
          This method get the ivon element as Julian Day integer.
 String getText()
          Deprecated.  
 MCRMetaHistoryDate.MCRMetaHistoryDateText getText(int index)
          This method return the MCRMetaHistoryDateTexts instance of the indexed element of the ArrayList.
 MCRMetaHistoryDate.MCRMetaHistoryDateText getText(String set_lang)
          This method return the MCRMetaHistoryDateTexts instance with the corresponding language.
 ArrayList<MCRMetaHistoryDate.MCRMetaHistoryDateText> getTexts()
          This method read the ArryList texts
 com.ibm.icu.util.Calendar getVon()
          This method get the von element as ICU-Calendar.
 String getVonToGregorianString()
          This method return the von as string.
 boolean isValid()
          This method checks the validation of the content of this class.
 void setBisDate(com.ibm.icu.util.Calendar set_date)
          This method set the bis to the given date of a supported calendar.
 void setBisDate(String set_date, String calstr)
          This method set the bis to the given date.
 void setCalendar(com.ibm.icu.util.Calendar cal)
          The method set the calendar String value.
 void setCalendar(String calstr)
          The method set the calendar String value.
 void setDefaultBis()
          The method set the bis values to the default.
 void setDefaultVon()
          The method set the von values to the default.
 void setFromDOM(Element element)
          This method reads the XML input stream part from a DOM part for the metadata of the document.
 void setText(String set_text)
          This method set the text field for the default language.
 void setText(String set_text, String set_lang)
          This method set the text field for the given language.
 void setVonDate(com.ibm.icu.util.Calendar set_date)
          This method set the von to the given date of a supported calendar.
 void setVonDate(String set_date, String calstr)
          This method set the von to the given date.
 int TextSize()
          This method read the size of texts
 
Methods inherited from class org.mycore.datamodel.metadata.MCRMetaDefault
debugDefault, decrementInherited, getDataPart, getInherited, getInheritedToString, getLang, getSubTag, getType, incrementInherited, setDataPart, setInherited, setLang, setSubTag, setType
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

protected static Logger LOGGER
Logger


MCRHISTORYDATE_MAX_TEXT

public static final int MCRHISTORYDATE_MAX_TEXT
The maximal length of 'text'

See Also:
Constant Field Values
Constructor Detail

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 set_datapart,
                          String set_subtag,
                          String default_lang,
                          String set_type,
                          int set_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 set_subtag. If the value of set_subtag is null or empty an exception was throwed. The type element was set to the value of set_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:
set_datapart - the global part of the elements like 'metadata' or 'service'
set_subtag - the name of the subtag
default_lang - the default language
set_type - the optional type string
set_inherted - a value >= 0
Throws:
MCRException - if the parameter values are invalid
Method Detail

setText

public final void setText(String set_text)
This method set the text field for the default language. If data exists, it overwrites the value of text.

Parameters:
set_text - the text string for a date or range

setText

public final void setText(String set_text,
                          String set_lang)
This method set the text field for the given language. If data exists, it overwrites the value of text.

Parameters:
set_text - the text string for a date or range
set_lang - the language of the text in the ISO format

addText

public final void addText(String set_text,
                          String set_lang)
This method add a MCRMetaHistoryDateTexts instance to the ArrayList of texts.

Parameters:
set_text - the text- String
set_lang - the lang- String

getText

public final MCRMetaHistoryDate.MCRMetaHistoryDateText getText(String set_lang)
This method return the MCRMetaHistoryDateTexts instance with the corresponding language.

Parameters:
set_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

public final ArrayList<MCRMetaHistoryDate.MCRMetaHistoryDateText> 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 cal)
The method set the calendar String value.

Parameters:
cal - 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 set_date)
This method set the von to the given date of a supported calendar.

Parameters:
set_date - the date of a ICU supported calendar.

setVonDate

public final void setVonDate(String set_date,
                             String calstr)
This method set the von to the given date.

Parameters:
set_date - a date string
calstr - the calendar as String, one of CALENDARS.

setBisDate

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

Parameters:
set_date - the date of a ICU supported calendar

setBisDate

public final void setBisDate(String set_date,
                             String calstr)
This method set the bis to the given date.

Parameters:
set_date - a date string
calstr - the calendar as String, one of CALENDARS.

getText

public final String getText()
Deprecated. 

This method get the 'text' text element.

Returns:
the text String of the default language or an empty String

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

getVonToGregorianString

public final String getVonToGregorianString()
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

getBisToGregorianString

public final String getBisToGregorianString()
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
Specified by:
createXML in class MCRMetaDefault
Returns:
a JDOM Element with the XML MCRMetaHistoryDate part
Throws:
MCRException - if the content of this class is not valid

isValid

public boolean isValid()
This method checks the validation of the content of this class. The method returns false if
  • the number of texts is 0 (empty texts are delete)
  • von is null or bis is null or calendar is null
otherwise the method returns true.

Specified by:
isValid in interface MCRMetaInterface
Overrides:
isValid in class MCRMetaDefault
Returns:
a boolean value

clone

public Object clone()
This method make a clone of this class.

Specified by:
clone in interface MCRMetaInterface
Specified by:
clone in class MCRMetaDefault

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