// MobyData.java
//
//    senger@ebi.ac.uk
//    May 2003
//

package org.biomoby.shared;



/**
 * A container keeping input or output data types together with few
 * other attributes. Together they tell what data a service can
 * have. Some of these types are 'primary' - they are used for service
 * discovery - the others are 'secondary' - they are here just for the
 * case that the registry needs to know about all service inputs and
 * outputs.
 *
 *<p>
 * @author <A HREF="mailto:senger@ebi.ac.uk">Martin Senger</A>
 * @version $Id: MobyData.java,v 1.7 2010/03/17 20:57:28 gordonp Exp $
 */

abstract public class MobyData implements Cloneable{

    protected String name;
    protected String id = null;
    /** Convenience for applications to associate any data with the Moby objects as needed for the 
	application's particular purpose.  Inspired by Java3D's scenegraph customization method. */
    protected Object userData = null;

    /**************************************************************************
     * Default constructor.
     *************************************************************************/
    public MobyData() {
	this ("_dummy_");
    }

    /**************************************************************************
     * Normal constructor. Other characteristics are empty - which is usually
     * wrong - therefore use 'set' method to fill them.
     *************************************************************************/
    public MobyData (String name) {
	setName (name);
    }

    public String getName() {
	return name;
    }
    public void setName (String value) {
	name = value;
    }

    public String getId() {
	return id;
    }
    public void setId (String value) {
	id = value;
    }
   
    /**
     * Retrieves any application-specific data that may have been stored in association with this Moby object.
     * The returned object has nothing to do with the Moby protocol itself.  See setUserData() for more details.
     */
    public Object getUserData(){
	return userData;
    }

    /**
     * Allows developers to track their application-specific information alongside the Moby functionality.
     * Provided for application developers' convenience: data stored using this routine is completely 
     * ignore by the Moby core libraries.  If you want to store Moby data, use the routines defined in various
     * subclasses of this class (e.g. MobyDataObject).
     */
    public void setUserData(Object data){
	userData = data;
    }

    /**************************************************************************
     * Must be overwritten by a subclass.
     *************************************************************************/
    abstract public MobyData clone();
    abstract public String toXML();
    abstract public boolean isPrimary();
    abstract public String format (int indent);

}
