Package org.mycore.datamodel.metadata
Class MCRObjectMetadata
java.lang.Object
org.mycore.datamodel.metadata.MCRObjectMetadata
- All Implemented Interfaces:
Iterable<MCRMetaElement>
This class implements all methode for handling one object metadata part. This
class uses only metadata type classes of the general datamodel code of
MyCoRe.
- Version:
- $Revision$ $Date$
- Author:
- Jens Kupferschmidt, Mathias Hegner
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
appendMetadata
(MCRObjectMetadata input) This method append MCRMetaElement's from a given MCRObjectMetadata to this data set.com.google.gson.JsonObject
Creates the JSON representation of this metadata container.final Element
This methode create a XML stream for all metadata.final void
debug()
This method put debug data to the logger (for the debug mode).final <T extends MCRMetaInterface>
Optional<T>Finds the first, not inheritedMCRMetaInterface
with the given tag.final <T extends MCRMetaInterface>
Optional<T>Finds the firstMCRMetaInterface
with the given tag where the inheritance level is equal the inherited value.final <T extends MCRMetaInterface>
Optional<T>Finds the first, not inheritedMCRMetaInterface
with the given tag where the @type attribute is equal to the given type.final <T extends MCRMetaInterface>
Optional<T>Finds the firstMCRMetaInterface
with the given tag where the inheritance level is equal the inherited value and the @type attribute is equal to the given type.final MCRObjectMetadata
getHeritableMetadata returns an instance of MCRObjectMetadata containing all the heritable MetaElement's of this object.final MCRMetaElement
getMetadataElement
(int index) This method return the MCRMetaElement selected by an index.final MCRMetaElement
getMetadataElement
(String tag) This method return the MCRMetaElement selected by tag.final boolean
isValid()
This methode check the validation of the content of this class.iterator()
final <T extends MCRMetaInterface>
List<T>Lists theMCRMetaInterface
s of the given tag.final void
removeInheritedMetadata removes all inherited metadata elementsfinal MCRMetaElement
removeMetadataElement
(int index) This method remove the MCRMetaElement selected a index from the list.final MCRMetaElement
This method remove the MCRMetaElement selected by tag from the list.final boolean
removeMetadataElement
(MCRMetaElement element) Removes the given element.final void
setFromDOM
(Element element) This methode read the XML input stream part from a DOM part for the metadata of the document.final void
sets the given MCRMetaElement to the list.int
size()
size returns the number of tag names in the ArrayList.final Stream<MCRMetaElement>
stream()
Streams theMCRMetaElement
's.final <T extends MCRMetaInterface>
Stream<T>Streams theMCRMetaInterface
s of the given tag.void
validate()
Validates this MCRObjectMetadata.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
MCRObjectMetadata
This is the constructor of the MCRObjectMetadata class. It set the default language for all metadata to the value from the configuration propertie MCR.Metadata.DefaultLang.- Throws:
MCRConfigurationException
- a special exception for configuartion data
-
-
Method Details
-
size
public int size()size returns the number of tag names in the ArrayList.- Returns:
- int number of tags and meta elements
-
getHeritableMetadata
getHeritableMetadata returns an instance of MCRObjectMetadata containing all the heritable MetaElement's of this object.- Returns:
- MCRObjectMetadata the heritable part of this MCRObjectMetadata
-
removeInheritedMetadata
public final void removeInheritedMetadata()removeInheritedMetadata removes all inherited metadata elements -
appendMetadata
This method append MCRMetaElement's from a given MCRObjectMetadata to this data set.- Parameters:
input
- the MCRObjectMetadata, that should merged into this data set
-
getMetadataElement
This method return the MCRMetaElement selected by tag. If this was not found, null was returned.- Parameters:
tag
- the element tag- Returns:
- the MCRMetaElement for the tag
-
getMetadataElement
This method return the MCRMetaElement selected by an index. If this was not found, null was returned.- Parameters:
index
- the element index- Returns:
- the MCRMetaElement for the index
-
setMetadataElement
sets the given MCRMetaElement to the list. If the tag exists the MCRMetaElement was replaced.- Parameters:
obj
- the MCRMetaElement object
-
removeMetadataElement
Removes the given element.- Parameters:
element
- the meta element to remove- Returns:
- true if the element was removed
-
removeMetadataElement
This method remove the MCRMetaElement selected by tag from the list.- Returns:
- true if set was successful, otherwise false
-
removeMetadataElement
This method remove the MCRMetaElement selected a index from the list.- Returns:
- true if set was successful, otherwise false
-
findFirst
Finds the first, not inheritedMCRMetaInterface
with the given tag.- Parameters:
tag
- the metadata tag e.g. 'maintitles'- Returns:
- an optional of the first meta interface
-
findFirst
Finds the first, not inheritedMCRMetaInterface
with the given tag where the @type attribute is equal to the given type. If the type is null, this method doesn't care if the @type attribute is set or not.- Parameters:
tag
- the metadata tag e.g. 'subtitles'type
- the @type attribute which have to match- Returns:
- an optional of the first meta interface
-
findFirst
Finds the firstMCRMetaInterface
with the given tag where the inheritance level is equal the inherited value.- Parameters:
tag
- the metadata tag e.g. 'maintitles'inherited
- level of inheritance. Zero is the current level, parent is one and so on.- Returns:
- an optional of the first meta interface
-
findFirst
public final <T extends MCRMetaInterface> Optional<T> findFirst(String tag, String type, Integer inherited) Finds the firstMCRMetaInterface
with the given tag where the inheritance level is equal the inherited value and the @type attribute is equal to the given type. If the type is null, this method doesn't care if the @type attribute is set or not.- Parameters:
tag
- the metadata tag e.g. 'subtitles'type
- the @type attribute which have to matchinherited
- level of inheritance. Zero is the current level, parent is one and so on.- Returns:
- an optional of the first meta interface
-
stream
Streams theMCRMetaElement
's.- Returns:
- stream of MCRMetaElement's
-
stream
Streams theMCRMetaInterface
s of the given tag.Stream<MCRMetaLangText> stream = mcrObjectMetadata.stream("maintitles");
- Parameters:
tag
- tag the metadata tag e.g. 'maintitles'- Returns:
- a stream of the requested meta interfaces
-
list
Lists theMCRMetaInterface
s of the given tag. This is not a live list. Removals or adds are not reflected on theMCRMetaElement
. UsegetMetadataElement(String)
for those operations.List<MCRMetaLangText> list = mcrObjectMetadata.list("maintitles");
- Parameters:
tag
- tag the metadata tag e.g. 'maintitles'- Returns:
- a list of the requested meta interfaces
-
setFromDOM
This methode read the XML input stream part from a DOM part for the metadata of the document.- Parameters:
element
- a list of relevant DOM elements for the metadata- Throws:
MCRException
- if a problem occured
-
createXML
This methode create a XML stream for all metadata.- Returns:
- a JDOM Element with the XML data of the metadata part
- Throws:
MCRException
- if the content of this class is not valid
-
createJSON
public com.google.gson.JsonObject createJSON()Creates the JSON representation of this metadata container.{ "def.maintitles": {
MCRMetaLangText.createJSON()
} "def.dates": {MCRMetaISO8601Date.createJSON()
} ... }- Returns:
- a json gson representation of this metadata container
-
isValid
public final boolean isValid()This methode check the validation of the content of this class. The methode returns true if- the array is empty
- the default lang value was supported
- Returns:
- a boolean value
-
validate
Validates this MCRObjectMetadata. This method throws an exception if:- one of the MCRMetaElement children is invalid
- Throws:
MCRException
- the MCRObjectMetadata is invalid
-
debug
public final void debug()This method put debug data to the logger (for the debug mode). -
iterator
- Specified by:
iterator
in interfaceIterable<MCRMetaElement>
-