Logo Search packages:      
Sourcecode: wims version File versions  Download package

LinkedElement.java

/*
$Id: LinkedElement.java,v 1.2 2003/02/18 11:48:48 sander Exp $
*/


package fr.ove.utils;

import java.io.Serializable;

/**
* A element of linked structure (queue, lists, etc..
* <P>
* Contains the element added in the structure and the reference to the previous
* and the next element in the structure.
*
* @author  2000 DIRAT Laurent
* @version 1.0 28/06/2000
*/
00019 public class LinkedElement implements Serializable {
    /**
    * The element in the structure.
    */
00023     private Object element;
    
    /**
    * The previous element in the structure.
    */
00028     private LinkedElement previous;
    
    /**
    * The next element in the structure.
    */
00033     private LinkedElement next;
    
    /**
    * The default contstructor
    */
00038     public LinkedElement() {
        this(null);
    }
    
    /**
    * The contstructor
    * @param element the element in the structure
    */
00046     public LinkedElement(Object element) {
        this.element = element;
        previous = null;
        next = null;
    }
    
    /**
    * Sets the element
    */
00055     public void setElement(Object element) {
        this.element = element;
    }
    
    /**
    * Returns the element
    */
00062     public Object getElement() {
        return element;
    }
    
    /**
    * Sets the previous element of the instance
    */
00069     public void setPrevious(LinkedElement previous) {
        this.previous = previous;
    }
    
    /**
    * Returns the previous element of the instance
    */
00076     public LinkedElement getPrevious() {
        return previous;
    }
    
    /**
    * Sets the next element of the instance
    */
00083     public void setNext(LinkedElement next) {
        this.next = next;
    }
    
    /**
    * Returns the next element of the instance
    */
00090     public LinkedElement getNext() {
        return next;
    }
    
    /**
    * Removes the instance from the structure
    */
00097     public void remove() {
        element = null;
        
        if (previous != null)
            previous.next = next;
            
        if (next != null)
            next.previous = previous;
    }
    
    /**
    * Returns a string representation of the element
    */
00110     public String toString() {
        return element.toString();
    }
}

Generated by  Doxygen 1.6.0   Back to index