/**
 * The class DNode is used to built doubly linked lists.
 * Each node contains an element and links to the next
 * and the previous node in the list.
 *
 * @version     1.2    May 15, 2000
 * @author      Franck van Breugel
 * @see Position
 */
public class DNode implements Position
{
    private Object element; // element stored in this node
    private DNode prev;    // previous node in list
    private DNode next;    // next node in list

    /** Constructs a DNode without element, previous and next node. */
    public DNode() 
    {
        this(null, null, null);
    }

    /** 
     * Constructs a DNode with specified element, previous and next node. 
     *
     * @param element the element stored in this node.
     * @param prev the previous node in the list.
     * @param next the next node in the list.
     */
    public DNode(DNode prev, DNode next, Object element) 
    {
        this.element = element;
        this.prev = prev;
        this.next = next;
    }

    /**
     * Sets the element stored in this node to the specified element.
     *
     * @param element The element to be stored in this node.
     */
    public void setElement(Object element) 
    {
        this.element = element;
    }

    /**
     * Sets the previous node in the list to the specified node.
     *
     * @param node The previous node in the list.
     */
    public void setPrev(DNode prev) 
    {
        this.prev = prev;
    }

    /**
     * Sets the next node in the list to the specified node.
     *
     * @param node The next node in the list.
     */
    public void setNext(DNode next) 
    {
        this.next = next;
    }

    /**
     * Returns the element stored in this node.
     *
     * @return The element stored in this node.
     */
    public Object element()
    {
        return element;
    }

    /**
     * Returns the previous node in the list.
     *
     * @return The previous node in the list.
     */
    public DNode getPrev() 
    {
        return prev;
    }

    /**
     * Returns the next node in the list.
     *
     * @return The next node in the list.
     */
    public DNode getNext() 
    {
        return next;
    }
}
