org.mycore.datamodel.metadata
Class MCRObjectStructure

java.lang.Object
  extended by org.mycore.datamodel.metadata.MCRObjectStructure

public class MCRObjectStructure
extends Object

This class implements code for the inheritance of metadata of linked objects and the linking of derivates onto an MCRObject. These links are described by the MCRMetaLink class. For links to another object, there are "locators" in use only, and the href variable gives the ID of the linked object, while the label and title attributes can be used freely. Subtag name = " " means a child link from a "parent" object (collected in the "children" and "parents" section of the "structure" part, respectively). The child inherits all heritable metadata of the parent. If the parent itself is a child of another parent, the heritable metadata of this "grand parent" is inherited by the child as well. This mechanism recursively traces the full inheritance hierarchy. So if the grand parent itself has a parent, this grand parent parent's heritable metadata will be inherited and so on. Note, that it is impossible to inherit metadata from multiple parents. In cases of multiple inheritance request, an exception is thrown. A child link cannot occur twice from the same object to the same href (preventing from doubled links). Not supported by this class are links from or to a defined place of a document (inner structure and combination of inner and outer structures of the objects). This will possibly be done in a later extension of MCRMetaLink and MCRObjectStructure.

Version:
$Revision: 14091 $ $Date: 2008-02-06 18:27:24 +0100 (Mi, 06 Feb 2008) $
Author:
Mathias Hegner, Jens Kupferschmidt

Constructor Summary
MCRObjectStructure(Logger log)
          The constructor initializes NL (non-static, in order to enable different NL's for different objects) and the link vectors the elements of which are MCRMetaLink's.
 
Method Summary
 boolean addChild(MCRMetaLinkID child)
          The method appends a child ID to the child link list if and only if it is not already contained in the list, preventing from doubly-linked objects.
 boolean addChild(MCRObjectID href, String label, String title)
          The method appends a child ID to the child link list if and only if it is not already contained in the list, preventing from doubly-linked objects.
 void addDerivate(MCRMetaLinkID add_derivate)
          addDerivate methode append the given derivate link data to the derivate vector.
(package private)  void clear()
          This method clean the data lists parent, children and derivates of this class.
(package private)  void clearChildren()
          This method clean the data lists children of this class.
(package private)  void clearDerivate()
          This method clean the data lists derivate of this class.
 Element createXML()
          createXML is the inverse of setFromDOM and converts the structure's memory copy into an XML string.
 MCRMetaLinkID getChild(int index)
          The method returns the child link at a given index.
 MCRObjectID getChildID(int index)
          The method return the child reference as a MCRObjectID.
 int getChildSize()
          The method returns the number of child links.
 MCRMetaLinkID getDerivate(int index)
          The method return the derivate form the array with the given index.
 int getDerivateSize()
          The method return the size of the derivate array.
 MCRMetaLinkID getParent()
          The method returns the parent link.
 MCRObjectID getParentID()
          The method return the parent reference as a MCRObjectID.
 boolean isValid()
          isValid checks whether all of the MCRMetaLink's in the link vectors are valid or not.
 boolean removeChild(MCRObjectID href)
          removeChild removes a child link to another object from the link vector.
 void removeDerivate(int index)
          removeDerivate the derivate link from the derivate vector for the given number.
 void setFromDOM(Element element)
          While the preceding methods dealt with the structure's copy in memory only, the following three will affect the operations to or from datastore too.
 void setParent(MCRMetaLinkID in_parent)
          This method set the parent value from a given MCRMetaLinkID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MCRObjectStructure

public MCRObjectStructure(Logger log)
The constructor initializes NL (non-static, in order to enable different NL's for different objects) and the link vectors the elements of which are MCRMetaLink's.

Method Detail

clear

final void clear()
This method clean the data lists parent, children and derivates of this class.


clearChildren

final void clearChildren()
This method clean the data lists children of this class.


clearDerivate

final void clearDerivate()
This method clean the data lists derivate of this class.


getParent

public final MCRMetaLinkID getParent()
The method returns the parent link.

Returns:
MCRMetaLinkID the corresponding link

getParentID

public final MCRObjectID getParentID()
The method return the parent reference as a MCRObjectID.

Returns:
the parent MCRObjectID.

setParent

public final void setParent(MCRMetaLinkID in_parent)
This method set the parent value from a given MCRMetaLinkID.

Parameters:
in_parent - the MCRMetaLinkID to set

addChild

public final boolean addChild(MCRMetaLinkID child)
The method appends a child ID to the child link list if and only if it is not already contained in the list, preventing from doubly-linked objects. If the link could be added a "true" will be returned, otherwise "false".

Parameters:
child - the MCRMetaLinkID of the child
Returns:
boolean true, if successfully done

addChild

public final boolean addChild(MCRObjectID href,
                              String label,
                              String title)
The method appends a child ID to the child link list if and only if it is not already contained in the list, preventing from doubly-linked objects. If the link could be added a "true" will be returned, otherwise "false".

Parameters:
href - the MCRObjectID string of the child
label - the link's label
title - the link's title
Returns:
boolean true, if successfully done

removeChild

public final boolean removeChild(MCRObjectID href)
removeChild removes a child link to another object from the link vector. If the link was found a "true" will be returned, otherwise "false".

Parameters:
href - the MCRObjectID of the child
Returns:
boolean true, if successfully completed

getChildSize

public final int getChildSize()
The method returns the number of child links.

Returns:
int number of children

getChild

public final MCRMetaLinkID getChild(int index)
The method returns the child link at a given index.

Parameters:
index - the index in the link vector
Returns:
MCRMetaLink the corresponding link

getChildID

public final MCRObjectID getChildID(int index)
The method return the child reference as a MCRObjectID.

Returns:
the child MCRObjectID.

addDerivate

public final void addDerivate(MCRMetaLinkID add_derivate)
addDerivate methode append the given derivate link data to the derivate vector. If the link could be added a "true" will be returned, otherwise "false".

Parameters:
add_derivate - the link to be added as MCRMetaLinkID

getDerivateSize

public final int getDerivateSize()
The method return the size of the derivate array.

Returns:
the size of the derivate array

getDerivate

public final MCRMetaLinkID getDerivate(int index)
                                throws IndexOutOfBoundsException
The method return the derivate form the array with the given index.

Parameters:
index - the index of the list
Returns:
the derivate as MCRMetaLinkID or null
Throws:
IndexOutOfBoundsException

removeDerivate

public final void removeDerivate(int index)
                          throws IndexOutOfBoundsException
removeDerivate the derivate link from the derivate vector for the given number.

Parameters:
index - the index of the link to be removed
Throws:
IndexOutOfBoundsException - throw this exception, if the index is false

setFromDOM

public final void setFromDOM(Element element)
While the preceding methods dealt with the structure's copy in memory only, the following three will affect the operations to or from datastore too. Thereby setFromDOM will read the structure data from an XML input stream (the "structure" entry).

Parameters:
element - the structure node list

createXML

public final Element createXML()
                        throws MCRException
createXML is the inverse of setFromDOM and converts the structure's memory copy into an XML string.

Returns:
org.jdom.Element the structure XML string
Throws:
MCRException - if the content of this class is not valid

isValid

public final boolean isValid()
isValid checks whether all of the MCRMetaLink's in the link vectors are valid or not.

Returns:
boolean true, if structure is valid