Class MCRMetaLink

java.lang.Object
org.mycore.datamodel.metadata.MCRMetaDefault
org.mycore.datamodel.metadata.MCRMetaLink
All Implemented Interfaces:
Cloneable, MCRMetaInterface
Direct Known Subclasses:
MCRMetaDerivateLink, MCRMetaLinkID

public class MCRMetaLink extends MCRMetaDefault
This class implements all method for generic handling with the MCRMetaLink part of a metadata object. The MCRMetaLink class present two types. At once a reference to an URL. At second a bidirectional link between two URL's. Optional you can append the reference with the label attribute. See to W3C XLink Standard for more informations.

<tag class="MCRMetaLink">
<subtag xlink:type="locator" xlink:href=" URL" xlink:label="..." xlink:title="..."/>
<subtag xlink:type="arc" xlink:from=" URL" xlink:to="URL"/>
</tag>

Author:
Jens Kupferschmidt
  • Field Details

    • href

      protected String href
    • label

      protected String label
    • title

      protected String title
    • linktype

      protected String linktype
    • role

      protected String role
    • from

      protected String from
    • to

      protected String to
  • Constructor Details

    • MCRMetaLink

      public MCRMetaLink()
      initializes with empty values.
    • MCRMetaLink

      public MCRMetaLink(String subtag, int inherted) throws MCRException
      This is the constructor.
      The language element was set. If the value of default_lang is null, empty or false en was set. The subtag element was set to the value of subtag. If the value of subtag is null or empty an exception was throwed.
      Parameters:
      subtag - the name of the subtag
      inherted - a value >= 0
      Throws:
      MCRException - if the set_datapart or subtag value is null or empty
  • Method Details

    • setReference

      public void setReference(String href, String label, String title) throws MCRException
      This method set a reference with xlink:href, xlink:label and xlink:title.
      Parameters:
      href - the reference
      label - the new label string
      title - the new title string
      Throws:
      MCRException - if the href value is null or empty
    • setBiLink

      public void setBiLink(String from, String to, String title) throws MCRException
      This method set a bidirectional link with xlink:from, xlink:to and xlink:title.
      Parameters:
      from - the source
      to - the target
      title - the new title string
      Throws:
      MCRException - if the from or to element is null or empty
    • getXLinkType

      public final String getXLinkType()
      This method get the xlink:type element.
      Returns:
      the xlink:type
    • getXLinkHref

      public final String getXLinkHref()
      This method get the xlink:href element as string.
      Returns:
      the xlink:href element as string
    • getXLinkLabel

      public final String getXLinkLabel()
      This method get the xlink:label element.
      Returns:
      the xlink:label
    • setXLinkLabel

      public final void setXLinkLabel(String label)
      This method set the xlink:label
      Parameters:
      label - the xlink:label
    • getXLinkTitle

      public final String getXLinkTitle()
      This method get the xlink:title element.
      Returns:
      the xlink:title
    • setXLinkTitle

      public final void setXLinkTitle(String title)
      This method set the xlink:title
      Parameters:
      title - the xlink:title
    • getXLinkFrom

      public final String getXLinkFrom()
      This method get the xlink:from element as string.
      Returns:
      the xlink:from element as string
    • getXLinkTo

      public final String getXLinkTo()
      This method get the xlink:to element as string.
      Returns:
      the xlink:to element as string
    • setXLinkRole

      public void setXLinkRole(String role)
      This method sets the xlink:role.
    • getXLinkRole

      public String getXLinkRole()
      This method get the xlink:role element as string.
    • compare

      public final boolean compare(MCRMetaLink input)
      The method compare this instance of MCRMetaLink with a input object of the class type MCRMetaLink. The both instances are equal, if:
      • for the type 'arc' the 'from' and 'to' element is equal
      • for the type 'locator' the 'href' element is equal

      Parameters:
      input - the MCRMetaLink input
      Returns:
      true if it is compare, else return false
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class MCRMetaDefault
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class MCRMetaDefault
    • setFromDOM

      public void setFromDOM(Element element) throws MCRException
      This method read the XML input stream part from a DOM part for the metadata of the document.
      Specified by:
      setFromDOM in interface MCRMetaInterface
      Overrides:
      setFromDOM in class MCRMetaDefault
      Parameters:
      element - a relevant DOM element for the metadata
      Throws:
      MCRException - if the xlink:type is not locator or arc or if href or from and to are null or empty
    • createXML

      public Element createXML() throws MCRException
      This method create a XML stream for all data in this class, defined by the MyCoRe XML MCRMetaLink definition for the given subtag.
      Specified by:
      createXML in interface MCRMetaInterface
      Overrides:
      createXML in class MCRMetaDefault
      Returns:
      a JDOM Element with the XML MCRMetaLink part
      Throws:
      MCRException - if the content of this class is not valid
    • createJSON

      public com.google.gson.JsonObject createJSON()
      Creates the JSON representation. Extends the MCRMetaDefault.createJSON() method with the following data. For linktype equals 'locator':
         {
           label: "MyCoRe Derivate Image",
           title: "MyCoRe Derivate Image",
           role: "image_reference",
           href: "mycore_derivate_00000001/image.tif"
         }
       
      For all other linktypes (arc):
         {
           label: "Link between Issue and Person",
           title: "Link between Issue and Person",
           role: "link",
           from: "mycore_issue_00000001",
           to: "mycore_person_00000001"
         }
       
      Specified by:
      createJSON in interface MCRMetaInterface
      Overrides:
      createJSON in class MCRMetaDefault
      Returns:
      a GSON object containing the json data of the metadata part
    • validate

      public void validate() throws MCRException
      Validates this MCRMetaLink. This method throws an exception if:
      • the subtag is not null or empty
      • the xlink:type not "locator" or "arc"
      • the from or to are not valid
      Specified by:
      validate in interface MCRMetaInterface
      Overrides:
      validate in class MCRMetaDefault
      Throws:
      MCRException - the MCRMetaLink is invalid
    • clone

      public MCRMetaLink clone()
      clone of this instance you will get a (deep) clone of this element
      Specified by:
      clone in interface MCRMetaInterface
      Overrides:
      clone in class MCRMetaDefault
      See Also:
    • debug

      public final void debug()
      This method put debug data to the logger (for the debug mode).
      Specified by:
      debug in interface MCRMetaInterface
      Overrides:
      debug in class MCRMetaDefault