Class MCRMetaDefault

java.lang.Object
org.mycore.datamodel.metadata.MCRMetaDefault
All Implemented Interfaces:
Cloneable, MCRMetaInterface
Direct Known Subclasses:
MCRMetaAccessRule, MCRMetaAddress, MCRMetaBoolean, MCRMetaClassification, MCRMetaHistoryDate, MCRMetaIFS, MCRMetaInstitutionName, MCRMetaISO8601Date, MCRMetaLangText, MCRMetaLink, MCRMetaNumber, MCRMetaPersonName, MCRMetaSpatial, MCRMetaXML

public abstract class MCRMetaDefault extends Object implements MCRMetaInterface
This class implements any methods for handling the basic data for all metadata classes of the metadata objects. The methods createXML() and createTypedContent() and createTextSearch() are abstract methods.
Version:
$Revision$ $Date$
Author:
Jens Kupferschmidt
  • Field Details

  • Constructor Details

    • MCRMetaDefault

      public MCRMetaDefault()
      This is the constructor.
      The language element was set to en . The datapart element was set to metadata All other elemnts was set to an empty string. The inherited value is set to 0!
    • MCRMetaDefault

      public MCRMetaDefault(String lang)
      This is the constructor.
      The language element was set. If the value of lang is empty or false en was set. The datapart was set to default. All other elemnts was set to an empty string. The inherited value is set to 0!
      Parameters:
      lang - the default language
    • MCRMetaDefault

      public MCRMetaDefault(String subtag, String lang, String type, int inherited) throws MCRException
      This is the constructor.
      The language element was set. If the value of 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 throwed. The type element was set to the value of type, if it is null, an empty string was set to the type element. The datapart element was set. If the value of datapart, is null or empty the default was set.
      Parameters:
      subtag - the name of the subtag
      lang - the language
      type - the optional type string
      inherited - a int value , > 0 if the data are inherited, else = 0.
      Throws:
      MCRException - if the subtag value is null or empty
    • MCRMetaDefault

      public MCRMetaDefault(String subtag, String lang, String type, int sequence, int inherited) throws MCRException
      This is the constructor.
      The language element was set. If the value of 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 throwed. The type element was set to the value of type, if it is null, an empty string was set to the type element. The datapart element was set. If the value of datapart, is null or empty the default was set.
      Parameters:
      subtag - the name of the subtag
      lang - the language
      type - the optional type string
      sequence - the optional sequence attribute as integer
      inherited - a int value , > 0 if the data are inherited, else = 0.
      Throws:
      MCRException - if the subtag value is null or empty
  • Method Details

    • setInherited

      public final void setInherited(int value)
      This method set the inherited level. This can be 0 or an integer higher 0.
      Specified by:
      setInherited in interface MCRMetaInterface
      Parameters:
      value - the inherited level value, if it is < 0, 0 is set
    • incrementInherited

      public final void incrementInherited()
      This method increments the inherited value with 1.
      Specified by:
      incrementInherited in interface MCRMetaInterface
    • decrementInherited

      public final void decrementInherited()
      This method decrements the inherited value with 1.
      Specified by:
      decrementInherited in interface MCRMetaInterface
    • setLang

      public final void setLang(String lang)
      This method set the language element. If the value of lang is null, empty or false nothing was changed.
      Specified by:
      setLang in interface MCRMetaInterface
      Parameters:
      lang - the language
    • setSubTag

      public final void setSubTag(String subtag) throws MCRException
      This method set the subtag element. If the value of subtag is null or empty an exception was throwed.
      Specified by:
      setSubTag in interface MCRMetaInterface
      Parameters:
      subtag - the subtag
      Throws:
      MCRException - if the subtag value is null or empty
    • setType

      public final void setType(String type)
      This method set the type element. If the value of type is null or empty nothing was changed.
      Specified by:
      setType in interface MCRMetaInterface
      Parameters:
      type - the optional type
    • setSequence

      public final void setSequence(int sequence)
      This method set the sequence element. If the value of sequence is null or empty nothing was changed.
      Parameters:
      sequence - the optional sequence attribute
    • getInherited

      public final int getInherited()
      This method get the inherited element.
      Specified by:
      getInherited in interface MCRMetaInterface
      Returns:
      the inherited flag as int
    • getLang

      public final String getLang()
      This method get the language element.
      Specified by:
      getLang in interface MCRMetaInterface
      Returns:
      the language
    • getSubTag

      public final String getSubTag()
      This method get the subtag element.
      Specified by:
      getSubTag in interface MCRMetaInterface
      Returns:
      the subtag
    • getType

      public final String getType()
      This method get the type element.
      Specified by:
      getType in interface MCRMetaInterface
      Returns:
      the type
    • getSequence

      public int getSequence()
      This method get the sequence element.
      Returns:
      the sequence element
    • setFromDOM

      public void setFromDOM(Element element) throws MCRException
      This method read the XML input stream part from a DOM part for the metadata of the document.
      Specified by:
      setFromDOM in interface MCRMetaInterface
      Parameters:
      element - a relevant DOM element for the metadata
      Throws:
      MCRException - if the subtag value is null or empty
    • createXML

      public Element createXML() throws MCRException
      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
      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 a json object in the form of:
         {
           lang: "de",
           type: "title",
           sequence: "0001"
           inherited: 0
         }
       
      Specified by:
      createJSON in interface MCRMetaInterface
      Returns:
      a GSON object containing the json data of the metadata part
    • isValid

      public boolean isValid()
      This method check the validation of the content of this class. The method returns true if
      • the subtag is not null or empty
      • the lang value was supported
      otherwise the method return false
      Specified by:
      isValid in interface MCRMetaInterface
      Returns:
      a boolean value
    • validate

      public void validate() throws MCRException
      Validates this MCRMetaDefault. 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
      Specified by:
      validate in interface MCRMetaInterface
      Throws:
      MCRException - the MCRMetaDefault is invalid
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • debug

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

      public final void debugDefault()
      This method put common debug data to the logger (for the debug mode).
    • clone

      public MCRMetaDefault clone()
      Description copied from interface: MCRMetaInterface
      This method make a clone of this class.
      Specified by:
      clone in interface MCRMetaInterface
      Overrides:
      clone in class Object