Package org.mycore.datamodel.metadata
Class MCRBase
java.lang.Object
org.mycore.datamodel.metadata.MCRBase
- Direct Known Subclasses:
MCRDerivate
,MCRObject
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 Summary
Modifier and TypeFieldDescriptionprotected boolean
protected Document
protected static final String
protected MCRObjectID
protected String
protected final MCRObjectService
protected String
protected static final String
protected static final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncom.google.gson.JsonObject
Creates the JSON representation of this object.This method create a XML stream for all object data.final MCRObjectID
getId()
This methode return the object id.protected abstract String
final String
Method returns the object schema.final MCRObjectService
This methode return the instance of the MCRObjectService class.final String
This methode return the MyCoRe version of the data structure.boolean
boolean
isValid()
This method check the validation of the content of this class.protected void
setFromJDOM
(Document doc) protected final void
setFromURI
(URI uri) This method read the XML input stream from an URI to build up the MyCoRe-Object.protected final void
setFromXML
(byte[] xml, boolean valid) This method read the XML input stream from a byte array to build up the MyCoRe-Object.void
setId
(MCRObjectID id) This method set the object ID.void
setImportMode
(boolean importMode) final void
This methode set the object schema.protected void
setUp()
final void
setVersion
(String version) This methods set the MyCoRe version to the string 'Version 1.3'.toString()
void
validate()
Validates the content of this class.
-
Field Details
-
MCR_ENCODING
-
jdomDocument
-
mcrId
-
mcrVersion
-
mcrSchema
-
mcrService
-
NL
-
SLASH
-
importMode
protected boolean importMode
-
-
Constructor Details
-
MCRBase
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
-
setUp
protected void setUp() -
getId
This methode return the object id. If this is not set, null was returned.- Returns:
- the id as MCRObjectID
-
getVersion
This methode return the MyCoRe version of the data structure.- Returns:
- the version as a string
-
getSchema
Method returns the object schema. If the schema is not setnull
will be returned.- Returns:
- the schema as a string
-
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
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 MyCoReSAXParseException
IOException
-
setFromXML
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 MyCoReSAXParseException
-
setId
This method set the object ID.- Parameters:
id
- the object ID
-
setVersion
This methods set the MyCoRe version to the string 'Version 1.3'. -
setSchema
This methode set the object schema.- Parameters:
schema
- the object schema
-
createXML
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
-
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
- Returns:
- a boolean value
-
validate
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
-