Package org.mycore.datamodel.metadata
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
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 Summary
Modifier and TypeFieldDescriptionprotected String
protected String
protected String
protected String
protected String
protected String
protected String
Fields inherited from class org.mycore.datamodel.metadata.MCRMetaDefault
datapart, DEFAULT_ATTRIBUTE_INHERITED, DEFAULT_ATTRIBUTE_LANG, DEFAULT_ATTRIBUTE_SEQUENCE, DEFAULT_ATTRIBUTE_TYPE, DEFAULT_ELEMENT_DATAPART, DEFAULT_INHERITED, DEFAULT_LANG_LENGTH, DEFAULT_LANGUAGE, DEFAULT_SEQUENCE, DEFAULT_STRING_LENGTH, DEFAULT_TYPE_LENGTH, inherited, lang, NL, sequence, subtag, type
-
Constructor Summary
ConstructorDescriptioninitializes with empty values.MCRMetaLink
(String subtag, int inherted) This is the constructor. -
Method Summary
Modifier and TypeMethodDescriptionclone()
clone of this instance you will get a (deep) clone of this elementfinal boolean
compare
(MCRMetaLink input) The method compare this instance of MCRMetaLink with a input object of the class type MCRMetaLink.com.google.gson.JsonObject
Creates the JSON representation.This method create a XML stream for all data in this class, defined by the MyCoRe XML MCRMetaLink definition for the given subtag.final void
debug()
This method put debug data to the logger (for the debug mode).boolean
final String
This method get the xlink:from element as string.final String
This method get the xlink:href element as string.final String
This method get the xlink:label element.This method get the xlink:role element as string.final String
This method get the xlink:title element.final String
This method get the xlink:to element as string.final String
This method get the xlink:type element.int
hashCode()
void
This method set a bidirectional link with xlink:from, xlink:to and xlink:title.void
setFromDOM
(Element element) This method read the XML input stream part from a DOM part for the metadata of the document.void
setReference
(String href, String label, String title) This method set a reference with xlink:href, xlink:label and xlink:title.final void
setXLinkLabel
(String label) This method set the xlink:labelvoid
setXLinkRole
(String role) This method sets the xlink:role.final void
setXLinkTitle
(String title) This method set the xlink:titlevoid
validate()
Validates this MCRMetaLink.Methods inherited from class org.mycore.datamodel.metadata.MCRMetaDefault
debugDefault, decrementInherited, getInherited, getLang, getSequence, getSubTag, getType, incrementInherited, isValid, setInherited, setLang, setSequence, setSubTag, setType
-
Field Details
-
href
-
label
-
title
-
linktype
-
role
-
from
-
to
-
-
Constructor Details
-
MCRMetaLink
public MCRMetaLink()initializes with empty values. -
MCRMetaLink
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 subtaginherted
- a value >= 0- Throws:
MCRException
- if the set_datapart or subtag value is null or empty
-
-
Method Details
-
setReference
This method set a reference with xlink:href, xlink:label and xlink:title.- Parameters:
href
- the referencelabel
- the new label stringtitle
- the new title string- Throws:
MCRException
- if the href value is null or empty
-
setBiLink
This method set a bidirectional link with xlink:from, xlink:to and xlink:title.- Parameters:
from
- the sourceto
- the targettitle
- the new title string- Throws:
MCRException
- if the from or to element is null or empty
-
getXLinkType
This method get the xlink:type element.- Returns:
- the xlink:type
-
getXLinkHref
This method get the xlink:href element as string.- Returns:
- the xlink:href element as string
-
getXLinkLabel
This method get the xlink:label element.- Returns:
- the xlink:label
-
setXLinkLabel
This method set the xlink:label- Parameters:
label
- the xlink:label
-
getXLinkTitle
This method get the xlink:title element.- Returns:
- the xlink:title
-
setXLinkTitle
This method set the xlink:title- Parameters:
title
- the xlink:title
-
getXLinkFrom
This method get the xlink:from element as string.- Returns:
- the xlink:from element as string
-
getXLinkTo
This method get the xlink:to element as string.- Returns:
- the xlink:to element as string
-
setXLinkRole
This method sets the xlink:role. -
getXLinkRole
This method get the xlink:role element as string. -
compare
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 classMCRMetaDefault
-
equals
- Overrides:
equals
in classMCRMetaDefault
-
setFromDOM
This method read the XML input stream part from a DOM part for the metadata of the document.- Specified by:
setFromDOM
in interfaceMCRMetaInterface
- Overrides:
setFromDOM
in classMCRMetaDefault
- 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
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 interfaceMCRMetaInterface
- Overrides:
createXML
in classMCRMetaDefault
- 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 theMCRMetaDefault.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 interfaceMCRMetaInterface
- Overrides:
createJSON
in classMCRMetaDefault
- Returns:
- a GSON object containing the json data of the metadata part
-
validate
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 interfaceMCRMetaInterface
- Overrides:
validate
in classMCRMetaDefault
- Throws:
MCRException
- the MCRMetaLink is invalid
-
clone
clone of this instance you will get a (deep) clone of this element- Specified by:
clone
in interfaceMCRMetaInterface
- Overrides:
clone
in classMCRMetaDefault
- See Also:
-
debug
public final void debug()This method put debug data to the logger (for the debug mode).- Specified by:
debug
in interfaceMCRMetaInterface
- Overrides:
debug
in classMCRMetaDefault
-