// CommonNode.java
//
// Created: September 2005
//
// This file is a component of the BioMoby project.
// Copyright Martin Senger (martin.senger@gmail.com).
//

package org.biomoby.service.dashboard;

/**
 * A common node for various tree used in the dashboard. It contains
 * two Strings - one is used to display the node ('name'), the second
 * one to keep the real meaning of the node ('value'). It can have
 * also a 'type' which make it easire when different nodes are
 * present. <p>
 *
 * @author <A HREF="mailto:martin.senger@gmail.com">Martin Senger</A>
 * @version $Id: CommonNode.java,v 1.4 2005/11/21 17:17:27 senger Exp $
 */

public class CommonNode {
    private String value;   // what this node means   TBD: should be an Object
    private int type;       // also what this node means
    private String name;    // what this node displays

    public static final int NODE_DATA_TYPE    = 11;
    public static final int NODE_NAMESPACE    = 12;
    public static final int NODE_SERVICE_TYPE = 13;
    public static final int NODE_SERVICE      = 14;
    public static final int NODE_AUTHORITY    = 15;

    /*********************************************************************
     * Constructor
     ********************************************************************/
    protected CommonNode() {
    }

    /*********************************************************************
     * Usual constructor that sets both, meaning and appearance, to the
     * same value.
     ********************************************************************/
    public CommonNode (String value) {
	setValue (value);
	setName (value);
    }

    /*********************************************************************
     * Another constructor setting separately meaning ('value') and
     * appearance ('name').
     ********************************************************************/
    public CommonNode (String name, String value) {
	setValue (value);
	setName (name);
    }

    /*********************************************************************
     * A constructor that sets both, meaning and appearance, to the
     * same value, and add a node type.
     ********************************************************************/
    public CommonNode (String value, int type) {
	this (value);
	setType (type);
    }

    /*********************************************************************
     * Another constructor setting separately meaning ('value') and
     * appearance ('name'), and a node type.
     ********************************************************************/
    public CommonNode (String name, String value, int type) {
	this (name, value);
	setType (type);
    }

    /*********************************************************************
     * Return back the meaning of this node.
     ********************************************************************/
    public String getValue() {
	return value;
    }

    /*********************************************************************
     * Change the meaning of this node.
     ********************************************************************/
    public void setValue (String value) {
	this.value = value;
    }

    /*********************************************************************
     * Change the appearance of this node.
     ********************************************************************/
    public void setName (String name) {
	this.name = name;
    }

    /*********************************************************************
     * Return back the appearance of this node.
     ********************************************************************/
    public String getName() {
	return name;
    }

    /*********************************************************************
     * Change the type of this node.
     ********************************************************************/
    public void setType (int type) {
	this.type = type;
    }

    /*********************************************************************
     * Return back the type of this node.
     ********************************************************************/
    public int getType() {
	return type;
    }

    /*********************************************************************
     *
     ********************************************************************/
    public String toString() {
	return name;
    }
}
