Package org.mycore.datamodel.metadata
Class MCRMetaDefault
java.lang.Object
org.mycore.datamodel.metadata.MCRMetaDefault
- All Implemented Interfaces:
Cloneable
,MCRMetaInterface
- Direct Known Subclasses:
MCRMetaAccessRule
,MCRMetaAddress
,MCRMetaBoolean
,MCRMetaClassification
,MCRMetaHistoryDate
,MCRMetaIFS
,MCRMetaInstitutionName
,MCRMetaISO8601Date
,MCRMetaLangText
,MCRMetaLink
,MCRMetaNumber
,MCRMetaPersonName
,MCRMetaSpatial
,MCRMetaXML
This class implements any methods for handling the basic data for all
metadata classes of the metadata objects. The methods createXML() and
createTypedContent() and createTextSearch() are abstract methods.
- Version:
- $Revision$ $Date$
- Author:
- Jens Kupferschmidt
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final int
static final int
protected static final String
protected static final int
static final int
static final int
protected int
protected String
protected static final String
protected int
protected String
protected String
-
Constructor Summary
ConstructorDescriptionThis is the constructor.MCRMetaDefault
(String lang) This is the constructor.MCRMetaDefault
(String subtag, String lang, String type, int inherited) This is the constructor.MCRMetaDefault
(String subtag, String lang, String type, int sequence, int inherited) This is the constructor. -
Method Summary
Modifier and TypeMethodDescriptionclone()
This method make a clone of this class.com.google.gson.JsonObject
Creates a json object in the form of:This abstract method create a XML stream for all data in this class, defined by the MyCoRe XML MCRMeta... definition for the given subtag.void
debug()
This method put debug data to the logger (for the debug mode).final void
This method put common debug data to the logger (for the debug mode).final void
This method decrements the inherited value with 1.boolean
final int
This method get the inherited element.final String
getLang()
This method get the language element.int
This method get the sequence element.final String
This method get the subtag element.final String
getType()
This method get the type element.int
hashCode()
final void
This method increments the inherited value with 1.boolean
isValid()
This method check the validation of the content of this class.void
setFromDOM
(Element element) This method read the XML input stream part from a DOM part for the metadata of the document.final void
setInherited
(int value) This method set the inherited level.final void
This method set the language element.final void
setSequence
(int sequence) This method set the sequence element.final void
This method set the subtag element.final void
This method set the type element.void
validate()
Validates this MCRMetaDefault.
-
Field Details
-
DEFAULT_LANG_LENGTH
public static final int DEFAULT_LANG_LENGTH- See Also:
-
DEFAULT_TYPE_LENGTH
public static final int DEFAULT_TYPE_LENGTH- See Also:
-
DEFAULT_STRING_LENGTH
public static final int DEFAULT_STRING_LENGTH- See Also:
-
NL
-
DEFAULT_LANGUAGE
-
DEFAULT_ELEMENT_DATAPART
- See Also:
-
DEFAULT_ATTRIBUTE_INHERITED
- See Also:
-
DEFAULT_ATTRIBUTE_LANG
- See Also:
-
DEFAULT_ATTRIBUTE_SEQUENCE
- See Also:
-
DEFAULT_ATTRIBUTE_TYPE
- See Also:
-
DEFAULT_INHERITED
protected static final int DEFAULT_INHERITED- See Also:
-
DEFAULT_SEQUENCE
protected static final int DEFAULT_SEQUENCE- See Also:
-
subtag
-
lang
-
type
-
sequence
protected int sequence -
inherited
protected int inherited -
datapart
-
-
Constructor Details
-
MCRMetaDefault
public MCRMetaDefault()This is the constructor.
The language element was set to en . The datapart element was set to metadata All other elemnts was set to an empty string. The inherited value is set to 0! -
MCRMetaDefault
This is the constructor.
The language element was set. If the value of lang is empty or false en was set. The datapart was set to default. All other elemnts was set to an empty string. The inherited value is set to 0!- Parameters:
lang
- the default language
-
MCRMetaDefault
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 throwed. The type element was set to the value of type, if it is null, an empty string was set to the type element. The datapart element was set. If the value of datapart, is null or empty the default was set.- Parameters:
subtag
- the name of the subtaglang
- the languagetype
- the optional type stringinherited
- a int value , > 0 if the data are inherited, else = 0.- Throws:
MCRException
- if the subtag value is null or empty
-
MCRMetaDefault
public MCRMetaDefault(String subtag, String lang, String type, int sequence, int inherited) 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 throwed. The type element was set to the value of type, if it is null, an empty string was set to the type element. The datapart element was set. If the value of datapart, is null or empty the default was set.- Parameters:
subtag
- the name of the subtaglang
- the languagetype
- the optional type stringsequence
- the optional sequence attribute as integerinherited
- a int value , > 0 if the data are inherited, else = 0.- Throws:
MCRException
- if the subtag value is null or empty
-
-
Method Details
-
setInherited
public final void setInherited(int value) This method set the inherited level. This can be 0 or an integer higher 0.- Specified by:
setInherited
in interfaceMCRMetaInterface
- Parameters:
value
- the inherited level value, if it is < 0, 0 is set
-
incrementInherited
public final void incrementInherited()This method increments the inherited value with 1.- Specified by:
incrementInherited
in interfaceMCRMetaInterface
-
decrementInherited
public final void decrementInherited()This method decrements the inherited value with 1.- Specified by:
decrementInherited
in interfaceMCRMetaInterface
-
setLang
This method set the language element. If the value of lang is null, empty or false nothing was changed.- Specified by:
setLang
in interfaceMCRMetaInterface
- Parameters:
lang
- the language
-
setSubTag
This method set the subtag element. If the value of subtag is null or empty an exception was throwed.- Specified by:
setSubTag
in interfaceMCRMetaInterface
- Parameters:
subtag
- the subtag- Throws:
MCRException
- if the subtag value is null or empty
-
setType
This method set the type element. If the value of type is null or empty nothing was changed.- Specified by:
setType
in interfaceMCRMetaInterface
- Parameters:
type
- the optional type
-
setSequence
public final void setSequence(int sequence) This method set the sequence element. If the value of sequence is null or empty nothing was changed.- Parameters:
sequence
- the optional sequence attribute
-
getInherited
public final int getInherited()This method get the inherited element.- Specified by:
getInherited
in interfaceMCRMetaInterface
- Returns:
- the inherited flag as int
-
getLang
This method get the language element.- Specified by:
getLang
in interfaceMCRMetaInterface
- Returns:
- the language
-
getSubTag
This method get the subtag element.- Specified by:
getSubTag
in interfaceMCRMetaInterface
- Returns:
- the subtag
-
getType
This method get the type element.- Specified by:
getType
in interfaceMCRMetaInterface
- Returns:
- the type
-
getSequence
public int getSequence()This method get the sequence element.- Returns:
- the sequence element
-
setFromDOM
This method read the XML input stream part from a DOM part for the metadata of the document.- Specified by:
setFromDOM
in interfaceMCRMetaInterface
- Parameters:
element
- a relevant DOM element for the metadata- Throws:
MCRException
- if the subtag value is null or empty
-
createXML
This abstract method create a XML stream for all data in this class, defined by the MyCoRe XML MCRMeta... definition for the given subtag.- Specified by:
createXML
in interfaceMCRMetaInterface
- Returns:
- a JDOM Element with the XML MCRMeta... part
- Throws:
MCRException
- if the content of this class is not valid
-
createJSON
public com.google.gson.JsonObject createJSON()Creates a json object in the form of:{ lang: "de", type: "title", sequence: "0001" inherited: 0 }
- Specified by:
createJSON
in interfaceMCRMetaInterface
- Returns:
- a GSON object containing the json data of the metadata part
-
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 lang value was supported
- Specified by:
isValid
in interfaceMCRMetaInterface
- Returns:
- a boolean value
-
validate
Validates this MCRMetaDefault. 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
- Specified by:
validate
in interfaceMCRMetaInterface
- Throws:
MCRException
- the MCRMetaDefault is invalid
-
hashCode
public int hashCode() -
equals
-
debug
public void debug()This method put debug data to the logger (for the debug mode).- Specified by:
debug
in interfaceMCRMetaInterface
-
debugDefault
public final void debugDefault()This method put common debug data to the logger (for the debug mode). -
clone
Description copied from interface:MCRMetaInterface
This method make a clone of this class.- Specified by:
clone
in interfaceMCRMetaInterface
- Overrides:
clone
in classObject
-