org.mycore.datamodel.metadata
Class MCRMetaISO8601Date

java.lang.Object
  extended by org.mycore.datamodel.metadata.MCRMetaDefault
      extended by 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: 15160 $ $Date: 2009-05-08 09:35:46 +0200 (Fri, 08 May 2009) $
Author:
Thomas Scheffler (yagee)

Nested Class Summary
protected static class MCRMetaISO8601Date.FormatChooser
          is a helper class for MCRMetaISO8601Date.
static class MCRMetaISO8601Date.IsoFormat
           
 
Field Summary
 
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
MCRMetaISO8601Date()
          constructs a empty instance.
MCRMetaISO8601Date(String set_datapart, String set_subtag, String set_type, int set_inherted)
          same as superImplentation but sets lang attribute to "null"
 
Method Summary
 Object clone()
          clone of this instance you will get a (deep) clone of this element
 Element createXML()
          This abstract method create a XML stream for all data in this class, defined by the MyCoRe XML MCRMeta...
 void debug()
          This method put debug data to the logger (for the debug mode).
 String format(String format, Locale locale)
          formats the date to a String
 Date getDate()
          returns the Date representing this element.
 MCRMetaISO8601Date.IsoFormat getFormat()
          gets the input and output format.
 String getISOString()
          returns a ISO 8601 conform String using the current set format.
protected static Namespace getNs()
          returns the namespace of this element
 boolean isValid()
          checks the formal correctness of this element.
 void setDate(Date dt)
          sets the date for this meta data object
 void setDate(String isoString)
          sets the date for this meta data object
 void setFormat(MCRMetaISO8601Date.IsoFormat isoFormat)
          sets the input and output format.
 void setFormat(String format)
          sets the input and output format.
 void setFromDOM(Element element)
          This method read the XML input stream part from a DOM part for the metadata of the document.
 
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
 

Constructor Detail

MCRMetaISO8601Date

public MCRMetaISO8601Date()
constructs a empty instance.

See Also:
MCRMetaDefault.MCRMetaDefault()

MCRMetaISO8601Date

public MCRMetaISO8601Date(String set_datapart,
                          String set_subtag,
                          String set_type,
                          int set_inherted)
same as superImplentation but sets lang attribute to "null"

See Also:
MCRMetaDefault.MCRMetaDefault(String, String, String, String, int)
Method Detail

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
Specified by:
createXML in class MCRMetaDefault
Returns:
a JDOM Element with the XML MCRMeta... part
Throws:
MCRException - if the content of this class is not valid

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 final 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 final 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 final 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.

setFormat

public void setFormat(MCRMetaISO8601Date.IsoFormat isoFormat)
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.


format

public String format(String format,
                     Locale locale)
formats the date to a String

Parameters:
format - as in DateTimeFormat
locale - used by format process
Returns:
null if date is not set yet

getFormat

public MCRMetaISO8601Date.IsoFormat getFormat()
gets the input and output format. this is a String that is also exported as static fields by this class, or null if not defined.

Returns:
a format string that is valid conforming to xsd:duration schema type, or null if not defined.

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 Object clone()
clone of this instance you will get a (deep) clone of this element

Specified by:
clone in interface MCRMetaInterface
Specified by:
clone in class MCRMetaDefault
See Also:
Object.clone()

isValid

public boolean isValid()
checks the formal correctness of this element. This check includes:
  1. the included date is set
  2. the super implementation returns true

Specified by:
isValid in interface MCRMetaInterface
Overrides:
isValid in class MCRMetaDefault
Returns:
false, if any test fails and the instance should not be used for persistence purposes
See Also:
MCRMetaDefault.isValid()