Class MCRBase

java.lang.Object
org.mycore.datamodel.metadata.MCRBase
Direct Known Subclasses:
MCRDerivate, MCRObject

public abstract class MCRBase extends Object
This class is a abstract basic class for objects in the MyCoRe Project. It is the frame to produce a full functionality object.
Version:
$Revision$ $Date$
Author:
Jens Kupferschmidt
  • Field Details

    • MCR_ENCODING

      protected static final String MCR_ENCODING
    • jdomDocument

      protected Document jdomDocument
    • mcrId

      protected MCRObjectID mcrId
    • mcrVersion

      protected String mcrVersion
    • mcrSchema

      protected String mcrSchema
    • mcrService

      protected final MCRObjectService mcrService
    • NL

      protected static final String NL
    • SLASH

      protected static final String SLASH
    • importMode

      protected boolean importMode
  • Constructor Details

    • MCRBase

      public MCRBase() throws MCRException
      This is the constructor of the MCRBase class. It make an instance of the parser class and the metadata class.
      Throws:
      MCRException - general Exception of MyCoRe
  • Method Details

    • setFromJDOM

      protected void setFromJDOM(Document doc)
    • setUp

      protected void setUp()
    • getId

      public final MCRObjectID getId()
      This methode return the object id. If this is not set, null was returned.
      Returns:
      the id as MCRObjectID
    • getVersion

      public final String getVersion()
      This methode return the MyCoRe version of the data structure.
      Returns:
      the version as a string
    • getSchema

      public final String getSchema()
      Method returns the object schema. If the schema is not set null will be returned.
      Returns:
      the schema as a string
    • getService

      public final MCRObjectService getService()
      This methode return the instance of the MCRObjectService class. If this was not found, null was returned.
      Returns:
      the instance of the MCRObjectService class
    • setFromURI

      protected final void setFromURI(URI uri) throws MCRException, SAXParseException, IOException
      This method read the XML input stream from an URI to build up the MyCoRe-Object.
      Parameters:
      uri - an URI
      Throws:
      MCRException - general Exception of MyCoRe
      SAXParseException
      IOException
    • setFromXML

      protected final void setFromXML(byte[] xml, boolean valid) throws MCRException, SAXParseException
      This method read the XML input stream from a byte array to build up the MyCoRe-Object.
      Parameters:
      xml - a XML string
      Throws:
      MCRException - general Exception of MyCoRe
      SAXParseException
    • setId

      public void setId(MCRObjectID id)
      This method set the object ID.
      Parameters:
      id - the object ID
    • setVersion

      public final void setVersion(String version)
      This methods set the MyCoRe version to the string 'Version 1.3'.
    • setSchema

      public final void setSchema(String schema)
      This methode set the object schema.
      Parameters:
      schema - the object schema
    • createXML

      public Document createXML() throws MCRException
      This method create a XML stream for all object data.
      Returns:
      a JDOM Document with the XML data of the object as byte array
      Throws:
      MCRException - if the content of this class is not valid
    • createJSON

      public com.google.gson.JsonObject createJSON()
      Creates the JSON representation of this object.
         {
           id: "mycore_project_00000001",
           version: "3.0"
         }
       
    • getRootTagName

      protected abstract String getRootTagName()
    • isValid

      public boolean isValid()
      This method check the validation of the content of this class. The method returns true if
      • the mcr_id value is valid
      otherwise the method return false
      Returns:
      a boolean value
    • validate

      public void validate() throws MCRException
      Validates the content of this class. This method throws an exception if:
      • the mcr_id is null
      • the XML schema is null or empty
      • the service part is null or invalid
      Throws:
      MCRException - the content is invalid
    • isImportMode

      public boolean isImportMode()
    • setImportMode

      public void setImportMode(boolean importMode)
    • toString

      public String toString()
      Overrides:
      toString in class Object