org.mycore.datamodel.metadata
Class MCRMetaLink

java.lang.Object
  extended by org.mycore.datamodel.metadata.MCRMetaDefault
      extended by 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>

Version:
$Revision: 15275 $ $Date: 2009-05-26 14:49:44 +0200 (Tue, 26 May 2009) $
Author:
Jens Kupferschmidt

Field Summary
protected  String from
           
protected  String href
           
protected  String label
           
protected  String linktype
           
static int MAX_XLINK_FROM_LENGTH
          The length of XLink:from *
static int MAX_XLINK_HREF_LENGTH
          The length of XLink:href *
static int MAX_XLINK_LABEL_LENGTH
          The length of XLink:label *
static int MAX_XLINK_TITLE_LENGTH
          The length of XLink:title *
static int MAX_XLINK_TO_LENGTH
          The length of XLink:to *
static int MAX_XLINK_TYPE_LENGTH
          The length of XLink:type *
protected  String title
           
protected  String to
           
 
Fields inherited from class org.mycore.datamodel.metadata.MCRMetaDefault
datapart, DEFAULT_DATAPART, DEFAULT_INHERITED, DEFAULT_LANG_LENGTH, DEFAULT_LANGUAGE, DEFAULT_STRING_LENGTH, DEFAULT_TYPE_LENGTH, inherited, lang, LOGGER, NL, subtag, type
 
Constructor Summary
MCRMetaLink()
          This is the constructor.
MCRMetaLink(String set_datapart, String set_subtag, String default_lang, int set_inherted)
          This is the constructor.
 
Method Summary
 Object clone()
          This method make a clone of this class.
 boolean compare(MCRMetaLink input)
          The methode compare this instance of MCRMetaLink with a input object of the class type MCRMetaLink.
 Element createXML()
          This method create a XML stream for all data in this class, defined by the MyCoRe XML MCRMetaLink definition for the given subtag.
 void debug()
          This method put debug data to the logger (for the debug mode).
 String getXLinkFrom()
          This method get the xlink:from element as string.
 String getXLinkHref()
          This method get the xlink:href element as string.
 String getXLinkLabel()
          This method get the xlink:label element.
 String getXLinkTitle()
          This method get the xlink:title element.
 String getXLinkTo()
          This method get the xlink:to element as string.
 String getXLinkType()
          This method get the xlink:type element.
 boolean isValid()
          This method check the validation of the content of this class.
 void setBiLink(String set_from, String set_to, String set_title)
          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 set_href, String set_label, String set_title)
          This method set a reference with xlink:href, xlink:label and xlink:title.
 void setXLinkLabel(String label)
          This method set the xlink:label
 void setXLinkTitle(String title)
          This method set the xlink:title
 
Methods inherited from class org.mycore.datamodel.metadata.MCRMetaDefault
debugDefault, decrementInherited, getDataPart, getInherited, getInheritedToString, getLang, getSubTag, getType, incrementInherited, setDataPart, setInherited, setLang, setSubTag, setType
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_XLINK_TYPE_LENGTH

public static final int MAX_XLINK_TYPE_LENGTH
The length of XLink:type *

See Also:
Constant Field Values

MAX_XLINK_HREF_LENGTH

public static final int MAX_XLINK_HREF_LENGTH
The length of XLink:href *

See Also:
Constant Field Values

MAX_XLINK_LABEL_LENGTH

public static final int MAX_XLINK_LABEL_LENGTH
The length of XLink:label *

See Also:
Constant Field Values

MAX_XLINK_TITLE_LENGTH

public static final int MAX_XLINK_TITLE_LENGTH
The length of XLink:title *

See Also:
Constant Field Values

MAX_XLINK_FROM_LENGTH

public static final int MAX_XLINK_FROM_LENGTH
The length of XLink:from *

See Also:
Constant Field Values

MAX_XLINK_TO_LENGTH

public static final int MAX_XLINK_TO_LENGTH
The length of XLink:to *

See Also:
Constant Field Values

href

protected String href

label

protected String label

title

protected String title

linktype

protected String linktype

from

protected String from

to

protected String to
Constructor Detail

MCRMetaLink

public MCRMetaLink()
This is the constructor.
The language element was set to en . All other elemnts was set to an empty value.


MCRMetaLink

public MCRMetaLink(String set_datapart,
                   String set_subtag,
                   String default_lang,
                   int set_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 set_subtag. If the value of set_subtag is null or empty an exception was throwed.

Parameters:
set_datapart - the global part of the elements like 'metadata' or 'service' or so
set_subtag - the name of the subtag
default_lang - the default language
set_inherted - a value >= 0
Throws:
MCRException - if the set_datapart or set_subtag value is null or empty
Method Detail

setReference

public void setReference(String set_href,
                         String set_label,
                         String set_title)
                  throws MCRException
This method set a reference with xlink:href, xlink:label and xlink:title.

Parameters:
set_href - the reference
set_label - the new label string
set_title - the new title string
Throws:
MCRException - if the set_href value is null or empty

setBiLink

public void setBiLink(String set_from,
                      String set_to,
                      String set_title)
               throws MCRException
This method set a bidirectional link with xlink:from, xlink:to and xlink:title.

Parameters:
set_from - the source
set_to - the target
set_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

compare

public final boolean compare(MCRMetaLink input)
The methode 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

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
Specified by:
createXML in class MCRMetaDefault
Returns:
a JDOM Element with the XML MCRMetaLink part
Throws:
MCRException - if the content of this class is not valid

isValid

public boolean isValid()
This method check the validation of the content of this class. The method returns true if
  • the subtag is not null or empty
  • the xlink:type not "locator" or "arc"
  • the from or to are not valid
otherwise the method return false

Specified by:
isValid in interface MCRMetaInterface
Overrides:
isValid in class MCRMetaDefault
Returns:
a boolean value

clone

public final Object clone()
This method make a clone of this class.

Specified by:
clone in interface MCRMetaInterface
Specified by:
clone in class MCRMetaDefault

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