Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* This file is part of *** M y C o R e ***
* See http://www.mycore.de/ for details.
*
* MyCoRe is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MyCoRe is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with MyCoRe. If not, see .
*/
package org.mycore.datamodel.metadata;
import java.util.Objects;
import org.jdom2.Element;
import org.mycore.common.MCRException;
import org.mycore.common.MCRUtils;
import com.google.gson.JsonObject;
/**
* This class implements all methods for handling with the
* MCRMetaInstitutionName part of a metadata object. The MCRMetaInstitutionName
* class represents a name of an institution or corporation.
*
* @author J. Kupferschmidt
* @version $Revision$ $Date$
*/
public final class MCRMetaInstitutionName extends MCRMetaDefault {
// data
private String fullname;
private String nickname;
private String property;
/**
* This is the constructor.
* The language element was set to en . All other elemnts are set to
* an empty string.
*/
public MCRMetaInstitutionName() {
super();
fullname = "";
nickname = "";
property = "";
}
/**
* 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 fullname, nickname and property element
* was set to the value of set_..., if they are null,
* an empty string was set to this element.
* @param subtag the name of the subtag
* @param lang the default language
* @param type the optional type string
* @param inherted a value >= 0
* @param fullname the full name
* @param nickname the nickname
* @param property the property title
*
* @exception MCRException if the parameter values are invalid
*/
public MCRMetaInstitutionName(String subtag, String lang, String type, int inherted,
String fullname, String nickname, String property) throws MCRException {
super(subtag, lang, type, inherted);
this.fullname = "";
this.nickname = "";
this.property = "";
set(fullname, nickname, property);
}
/**
* This methode set all name componets.
*
* @param fullname
* the full name
* @param nickname
* the nickname
* @param property
* the property title
*/
public void set(String fullname, String nickname, String property) {
if (fullname == null || nickname == null || property == null) {
throw new MCRException("One parameter is null.");
}
this.fullname = fullname.trim();
this.nickname = nickname.trim();
this.property = property.trim();
}
/**
* This method get the name text element.
*
* @return the fullname
*/
public String getFullName() {
return fullname;
}
/**
* This method get the nickname text element.
*
* @return the nickname
*/
public String getNickname() {
return nickname;
}
/**
* This method get the property text element.
*
* @return the property
*/
public String getProperty() {
return property;
}
/**
* This method reads the XML input stream part from a DOM part for the
* metadata of the document.
*
* @param element
* a relevant DOM element for the metadata
*/
@Override
public void setFromDOM(Element element) {
super.setFromDOM(element);
fullname = element.getChildTextTrim("fullname");
if (fullname == null) {
fullname = "";
}
nickname = element.getChildTextTrim("nickname");
if (nickname == null) {
nickname = "";
}
property = element.getChildTextTrim("property");
if (property == null) {
property = "";
}
}
/**
* This method creates a XML stream for all data in this class, defined by
* the MyCoRe XML MCRMetaInstitutionName definition for the given subtag.
*
* @exception MCRException
* if the content of this class is not valid
* @return a JDOM Element with the XML MCRMetaInstitutionName part
*/
@Override
public Element createXML() throws MCRException {
Element elm = super.createXML();
elm.addContent(new Element("fullname").addContent(fullname));
nickname = nickname.trim();
if (nickname.length() != 0) {
elm.addContent(new Element("nickname").addContent(nickname));
}
property = property.trim();
if (property.length() != 0) {
elm.addContent(new Element("property").addContent(property));
}
return elm;
}
/**
* Creates the JSON representation. Extends the {@link MCRMetaDefault#createJSON()} method
* with the following data.
*
*