package de.uka.ipd.consensus.foundation.schema;

import java.io.Serializable;

import de.uka.ipd.consensus.foundation.ontology.OntologyManagerException;
import de.uka.ipd.consensus.foundation.rights.DynamicRightsManagerException;

/**
 * This interface represents an attribute (name/value pair) of a topic.
 * @author Thomas Much
 * @version 2006-06-14
 * @see Topic
 * @see Attributeable
 * @see de.uka.ipd.consensus.foundation.ontology.OntologyManager#createAttribute(User, String, String, String, Topic)
 */
public interface Attribute extends Concept,Serializable,Comparable {

	/**
	 * Returns the attribute's value.
	 * @return the attribute's value (may be an empty string, but never <code>null</code>)
	 */
	public String getValue();
	
	
	/**
	 * Changes the attribute's value.
	 * @param setter the user who wants to change the value
	 * @param value the new value (<code>null</code> is treated as an empty string)
	 * @throws OntologyManagerException if the value could not be changed
	 * @throws DynamicRightsManagerException if the user is not allowed to change the value
	 * @see de.uka.ipd.consensus.foundation.rights.DynamicRightsManager#mayChangeAttributeValue(User, Attribute)
	 */
	public void setValue(User setter, String value) throws OntologyManagerException,DynamicRightsManagerException;
	
	
	/**
	 * Returns the type of the attribute.
	 * @return the attribute's type or <code>null</code> if the attribute does not have a type
	 */
	public Topic getType();
	
	
	/**
	 * Sets the type of the attribute. If the implementation supports classes, the type must be a class topic.
	 * @param setter the user who wants to set the type
	 * @param type the type topic (or <code>null</code> to remove the type)
	 * @throws OntologyManagerException if the type could not be set
	 * @throws DynamicRightsManagerException if the user is not allowed to change the type
	 * @see Topic#isClassTopic()
	 */
	public void setType(User setter, Topic type) throws OntologyManagerException,DynamicRightsManagerException;
	
	
	/**
	 * Returns the element which this attribute belongs to.
	 * With the current schema definition, this can only be a Topic object.
	 * @return the topic which this attribute belongs to
	 * @see Topic
	 */
	public Attributeable getAttributeable();

}
