Package org.mycore.datamodel.metadata
Class MCRMetaLangText
java.lang.Object
org.mycore.datamodel.metadata.MCRMetaDefault
org.mycore.datamodel.metadata.MCRMetaLangText
- All Implemented Interfaces:
Cloneable
,MCRMetaInterface
- Direct Known Subclasses:
MCRMetaDateLangText
This class implements all method for handling with the MCRMetaLangText part
of a metadata object. The MCRMetaLangText class present a single item, which
has triples of a text and his corresponding language and optional a type.
- Version:
- $Revision$ $Date$
- Author:
- Jens Kupferschmidt
-
Field Summary
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
ConstructorDescriptionThis is the constructor.This is the constructor. -
Method Summary
Modifier and TypeMethodDescriptionclone()
clone of this instance you will get a (deep) clone of this elementcom.google.gson.JsonObject
Creates the JSON representation.This method create a XML stream for all data in this class, defined by the MyCoRe XML MCRMetaLangText definition for the given subtag.final void
debug()
This method put debug data to the logger (for the debug mode).boolean
Check the equivalence between this instance and the given object.final String
getForm()
This method get the form attribute.final String
getText()
This method get the text element.final void
This method set the language, type and text.final void
This method set the form attribute.void
setFromDOM
(Element element) This method read the XML input stream part from a DOM part for the metadata of the document.final void
This method set the text.void
validate()
Validates this MCRMetaLangText.Methods inherited from class org.mycore.datamodel.metadata.MCRMetaDefault
debugDefault, decrementInherited, getInherited, getLang, getSequence, getSubTag, getType, hashCode, incrementInherited, isValid, setInherited, setLang, setSequence, setSubTag, setType
-
Field Details
-
text
-
form
-
-
Constructor Details
-
MCRMetaLangText
public MCRMetaLangText()This is the constructor.
The language element was set to en . All other elements was set to an empty string. The form Attribute is set to 'plain'. -
MCRMetaLangText
public MCRMetaLangText(String subtag, String lang, String type, int inherted, String form, String text) throws MCRException This is the constructor.
The language element was set. If the value of 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 thrown. The type element was set to the value of type, if it is null, an empty string was set to the type element. The text element was set to the value of text, if it is null, an empty string was set to the text element.- Parameters:
subtag
- the name of the subtaglang
- the default languagetype
- the optional type stringinherted
- a value >= 0form
- the format string, if it is empty 'plain' is set.text
- the text string- Throws:
MCRException
- if the subtag value is null or empty
-
-
Method Details
-
set
This method set the language, type and text.- Parameters:
lang
- the new language string, if this is null or empty, nothing is to dotype
- the optional type stringtext
- the new text string
-
setText
This method set the text.- Parameters:
text
- the new text string
-
setForm
This method set the form attribute.- Parameters:
form
- the new form string
-
getText
This method get the text element.- Returns:
- the text
-
getForm
This method get the form attribute.- Returns:
- the form attribute
-
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 JDOM element for the metadata
-
createXML
This method create a XML stream for all data in this class, defined by the MyCoRe XML MCRMetaLangText definition for the given subtag.- Specified by:
createXML
in interfaceMCRMetaInterface
- Overrides:
createXML
in classMCRMetaDefault
- Returns:
- a JDOM Element with the XML MCRMetaLangText 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.{ text: "Hallo Welt", form: "plain" }
- Specified by:
createJSON
in interfaceMCRMetaInterface
- Overrides:
createJSON
in classMCRMetaDefault
- Returns:
- a GSON object containing the json data of the metadata part
-
validate
Validates this MCRMetaLangText. This method throws an exception if:- the subtag is not null or empty
- the lang value was supported
- the inherited value is lower than zero
- the trimmed text is null or empty
- Specified by:
validate
in interfaceMCRMetaInterface
- Overrides:
validate
in classMCRMetaDefault
- Throws:
MCRException
- the MCRMetaLangText 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
-
equals
Check the equivalence between this instance and the given object.- Overrides:
equals
in classMCRMetaDefault
- Parameters:
obj
- the MCRMetaLangText object- Returns:
- true if its equal
-