All Downloads are FREE. Search and download functionalities are using the official Maven repository.

buri.ddmsence.ddms.summary.Description Maven / Gradle / Ivy

Go to download

DDMSence (pronounced "dee-dee-em-Essence") is the only open-source Java library that fully supports the DoD Discovery Metadata Specification (DDMS).

The newest version!
/* Copyright 2010 - 2013 by Brian Uri!
   
   This file is part of DDMSence.
   
   This library is free software; you can redistribute it and/or modify
   it under the terms of version 3.0 of the GNU Lesser General Public 
   License as published by the Free Software Foundation.
   
   This library 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 Lesser General Public License for more details.
   
   You should have received a copy of the GNU Lesser General Public 
   License along with DDMSence. If not, see .

   You can contact the author at [email protected]. The DDMSence
   home page is located at http://ddmsence.urizone.net/
 */
package buri.ddmsence.ddms.summary;

import nu.xom.Element;
import buri.ddmsence.AbstractBaseComponent;
import buri.ddmsence.AbstractSimpleString;
import buri.ddmsence.ddms.IBuilder;
import buri.ddmsence.ddms.InvalidDDMSException;
import buri.ddmsence.ddms.security.ism.SecurityAttributes;
import buri.ddmsence.util.DDMSVersion;
import buri.ddmsence.util.Util;

/**
 * An immutable implementation of ddms:description.
 *  * 

* {@ddms.versions 11111} * *

* * {@table.header History} * None. * {@table.footer} * {@table.header Nested Elements} * None. * {@table.footer} * {@table.header Attributes} * {@child.info ism:classification|1|11111} * {@child.info ism:ownerProducer|1..*|11111} * {@child.info ism:<securityAttributes>|0..*|11111} * {@table.footer} * {@table.header Validation Rules} * {@ddms.rule The qualified name of this element must be correct.|Error|11111} * {@ddms.rule ism:classification must exist.|Error|11111} * {@ddms.rule ism:ownerProducer must exist.|Error|11111} * {@ddms.rule This component can be used with no values set.|Warning|11111} * {@table.footer} * * @author Brian Uri! * @since 0.9.b */ public final class Description extends AbstractSimpleString { /** * Constructor for creating a component from a XOM Element * * @param element the XOM element representing this * @throws InvalidDDMSException if any required information is missing or malformed */ public Description(Element element) throws InvalidDDMSException { super(element, true); } /** * Constructor for creating a component from raw data * * @param description the value of the description child text * @param securityAttributes any security attributes * @throws InvalidDDMSException if any required information is missing or malformed */ public Description(String description, SecurityAttributes securityAttributes) throws InvalidDDMSException { super(Description.getName(DDMSVersion.getCurrentVersion()), description, securityAttributes, true); } /** * @see AbstractBaseComponent#validate() */ protected void validate() throws InvalidDDMSException { Util.requireDDMSQName(getXOMElement(), Description.getName(getDDMSVersion())); super.validate(); } /** * @see AbstractBaseComponent#validateWarnings() */ protected void validateWarnings() { if (Util.isEmpty(getValue())) addWarning("A ddms:" + getName() + " element was found with no description value."); super.validateWarnings(); } /** * @see AbstractBaseComponent#getOutput(boolean, String, String) */ public String getOutput(boolean isHTML, String prefix, String suffix) { String localPrefix = buildPrefix(prefix, getName(), suffix); StringBuffer text = new StringBuffer(); text.append(buildOutput(isHTML, localPrefix, getValue())); text.append(getSecurityAttributes().getOutput(isHTML, localPrefix + ".")); return (text.toString()); } /** * Accessor for the element name of this component, based on the version of DDMS used * * @param version the DDMSVersion * @return an element name */ public static String getName(DDMSVersion version) { Util.requireValue("version", version); return ("description"); } /** * @see Object#equals(Object) */ public boolean equals(Object obj) { if (!super.equals(obj) || !(obj instanceof Description)) return (false); return (true); } /** * Builder for this DDMS component. * * @see IBuilder * @author Brian Uri! * @since 1.8.0 */ public static class Builder extends AbstractSimpleString.Builder { private static final long serialVersionUID = 7750664735441105296L; /** * Empty constructor */ public Builder() { super(); } /** * Constructor which starts from an existing component. */ public Builder(Description description) { super(description); } /** * @see IBuilder#commit() */ public Description commit() throws InvalidDDMSException { return (isEmpty() ? null : new Description(getValue(), getSecurityAttributes().commit())); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy