Package org.mycore.datamodel.metadata
Class MCRMetaElement
java.lang.Object
org.mycore.datamodel.metadata.MCRMetaElement
- All Implemented Interfaces:
Cloneable
,Iterable<MCRMetaInterface>
This class is designed to to have a basic class for all metadata. The class
has inside a ArrayList that holds all metaddata elements for one XML tag.
Furthermore, this class supports the linking of a document owing this
metadata element to another document, the id of which is given in the
xlink:href attribute of the MCRMetaLink representing the link. The class name
of such a metadata element must be MCRMetaLink, and the metadata element is
considered to be a folder of links.
- Version:
- $Revision$ $Date$
- Author:
- Jens Kupferschmidt, Mathias Hegner
-
Field Summary
-
Constructor Summary
ConstructorDescriptionThis is the constructor of the MCRMetaElement class.MCRMetaElement
(Class<? extends MCRMetaInterface> clazz, String tag, boolean heritable, boolean notinherit, List<? extends MCRMetaInterface> list) This is the constructor of the MCRMetaElement class. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
The method add a metadata object, that implements the MCRMetaInterface to this element.final MCRMetaElement
clone()
This method make a clone of this class.com.google.gson.JsonObject
createJSON
(boolean flag) Creates the JSON representation of this metadata element.final Element
createXML
(boolean flag) This methode create a XML stream for all data in this class, defined by the MyCoRe XML MCRLangText definition for the given subtag.final void
debug()
This method put debug data to the logger (for the debug mode).final String
This methode return the name of this metadata class as string.Class<? extends MCRMetaInterface>
getClazz()
final MCRMetaInterface
getElement
(int index) This method returns the instance of an element from the list with index i.final MCRMetaInterface
getElementByName
(String name) This method returns the instance of an element from the list with the given namefinal String
getTag()
This methode return the tag of this metadata class as string.final boolean
This methode return the nonherit flag of this metadata as boolean value.final boolean
This methode return the heritable flag of this metadata as boolean value.final boolean
isValid()
This methode check the validation of the content of this class.iterator()
final boolean
removeElement
(int index) This method remove the instance of an element from the list with index i.final void
The method removes all inherited metadata objects of this MCRMetaElement.final boolean
The method remove a metadata object, that implements the MCRMetaInterface to this element.final void
setClass
(Class<? extends MCRMetaInterface> clazz) This methode set the element class for the metadata elements.final void
setFromDOM
(Element element) This methode read the XML input stream part from a DOM part for the metadata of the document.void
setHeritable
(boolean heritable) This methode set the heritable flag for the metadata class.void
setNotInherit
(boolean notinherit) This methode set the notinherit flag for the metadata class.void
This methode set the tag for the metadata class.final int
size()
size returns the number of elements in this instance.stream()
Streams theMCRMetaInterface
of this element.void
validate()
Validates this MCRMetaElement.Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
DEFAULT_LANGUAGE
-
DEFAULT_HERITABLE
public static final boolean DEFAULT_HERITABLE -
DEFAULT_NOT_INHERIT
public static final boolean DEFAULT_NOT_INHERIT
-
-
Constructor Details
-
MCRMetaElement
public MCRMetaElement()This is the constructor of the MCRMetaElement class. The default language for the element was set to MCR.Metadata.DefaultLang. -
MCRMetaElement
public MCRMetaElement(Class<? extends MCRMetaInterface> clazz, String tag, boolean heritable, boolean notinherit, List<? extends MCRMetaInterface> list) This is the constructor of the MCRMetaElement class.- Parameters:
tag
- the name of this tagheritable
- set this flag to true if all child objects of this element can inherit this datanotinherit
- set this flag to true if this element should not inherit from his parent objectlist
- a list of MCRMeta... data lines to add in this element (can be null)
-
-
Method Details
-
getClassName
This methode return the name of this metadata class as string.- Returns:
- the name of this metadata class as string
-
getElement
This method returns the instance of an element from the list with index i.- Returns:
- the instance of an element, if index is out of range return null
-
getElementByName
This method returns the instance of an element from the list with the given name- Returns:
- the instance of the element with the given name or null if there is no such element
-
isHeritable
public final boolean isHeritable()This methode return the heritable flag of this metadata as boolean value.- Returns:
- the heritable flag of this metadata class
-
inheritsNot
public final boolean inheritsNot()This methode return the nonherit flag of this metadata as boolean value.- Returns:
- the notherit flag of this metadata class
-
getTag
This methode return the tag of this metadata class as string.- Returns:
- the tag of this metadata class as string
-
setHeritable
public void setHeritable(boolean heritable) This methode set the heritable flag for the metadata class.- Parameters:
heritable
- the heritable flag as boolean value
-
setNotInherit
public void setNotInherit(boolean notinherit) This methode set the notinherit flag for the metadata class.- Parameters:
notinherit
- the notinherit flag as boolean value
-
setTag
This methode set the tag for the metadata class.- Parameters:
tag
- the tag for the metadata class
-
setClass
This methode set the element class for the metadata elements.- Parameters:
clazz
- the class for the metadata elements
-
getClazz
-
size
public final int size()size returns the number of elements in this instance.- Returns:
- int the size of "list"
-
addMetaObject
The method add a metadata object, that implements the MCRMetaInterface to this element.- Parameters:
obj
- a metadata object- Throws:
MCRException
- if the class name of the object is not the same like the name of all store metadata in this element.
-
removeElement
public final boolean removeElement(int index) This method remove the instance of an element from the list with index i.- Returns:
- true if the instance is removed, otherwise return else
-
removeMetaObject
The method remove a metadata object, that implements the MCRMetaInterface to this element.- Parameters:
obj
- a metadata object- Returns:
- true if this
MCRMetaElement
contained the specifiedMCRMetaInterface
- Throws:
MCRException
- if the class name of the object is not the same like the name of all store metadata in this element.
-
removeInheritedMetadata
public final void removeInheritedMetadata()The method removes all inherited metadata objects of this MCRMetaElement. -
setFromDOM
This methode read the XML input stream part from a DOM part for the metadata of the document.- Parameters:
element
- a relevant JDOM element for the metadata- Throws:
MCRException
- if the class can't loaded
-
createXML
This methode create a XML stream for all data in this class, defined by the MyCoRe XML MCRLangText definition for the given subtag.- Parameters:
flag
- true if all inherited data should be include, else false- Returns:
- a JDOM Element with the XML Element part
- Throws:
MCRException
- if the content of this class is not valid
-
createJSON
public com.google.gson.JsonObject createJSON(boolean flag) Creates the JSON representation of this metadata element.{ class: 'MCRMetaLangText', heritable: true, notinherit: false, data: [
MCRMetaInterface.createJSON()
, ... ] }- Returns:
- a json gson representation of this metadata element
-
isValid
public final boolean isValid()This methode check the validation of the content of this class. The methode returns true if- the classname is not null or empty
- the tag is not null or empty
- if the list is empty
- the lang value was supported
- Returns:
- a boolean value
-
validate
Validates this MCRMetaElement. This method throws an exception if:- the classname is not null or empty
- the tag is not null or empty
- if the list is empty
- the lang value was supported
- Throws:
MCRException
- the MCRMetaElement is invalid
-
clone
This method make a clone of this class. -
debug
public final void debug()This method put debug data to the logger (for the debug mode). -
stream
Streams theMCRMetaInterface
of this element.- Returns:
- stream of MCRMetaInterface's
-
iterator
- Specified by:
iterator
in interfaceIterable<MCRMetaInterface>
-