net.sf.mmm.util.collection.base
Class BasicDoubleLinkedNode<V>

java.lang.Object
  extended by net.sf.mmm.util.collection.base.AbstractLinkedNode<V,BasicDoubleLinkedNode<V>>
      extended by net.sf.mmm.util.collection.base.BasicDoubleLinkedNode<V>
Type Parameters:
V - is the generic type of the value of this node.
All Implemented Interfaces:
DoubleLinkedNode<V,BasicDoubleLinkedNode<V>>, LinkedNode<V,BasicDoubleLinkedNode<V>>

public class BasicDoubleLinkedNode<V>
extends AbstractLinkedNode<V,BasicDoubleLinkedNode<V>>
implements DoubleLinkedNode<V,BasicDoubleLinkedNode<V>>

This is a basic implementation of the DoubleLinkedNode interface.

Since:
2.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Field Summary
private  BasicDoubleLinkedNode<V> previous
           
 
Constructor Summary
BasicDoubleLinkedNode()
          The constructor.
 
Method Summary
 BasicDoubleLinkedNode<V> getPrevious()
          This method gets the previous node of the double linked list.
 void insertAsNext(BasicDoubleLinkedNode<V> node)
          This method inserts the given node into the list immediately after the position represented by this node.
 BasicDoubleLinkedNode<V> insertAsNext(V value, boolean overrideNullValue)
          This method inserts the given value into the list at the position represented by this node.
 void insertAsPrevious(BasicDoubleLinkedNode<V> node)
          This method inserts the given node into the list immediately before the position represented by this node.
 BasicDoubleLinkedNode<V> insertAsPrevious(V value, boolean overrideNullValue)
          This method inserts the given value into the list at the position represented by this node.
 boolean isLinked()
          This method determines if this node is linked.
 void remove()
          This method removes this node from the double linked list.
 void setPrevious(BasicDoubleLinkedNode<V> previous)
          This method sets the previous node.
 
Methods inherited from class net.sf.mmm.util.collection.base.AbstractLinkedNode
addToList, getNext, getValue, setNext, setValue, toList, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sf.mmm.util.collection.api.LinkedNode
addToList, getNext, getValue, toList
 

Field Detail

previous

private BasicDoubleLinkedNode<V> previous
See Also:
getPrevious()
Constructor Detail

BasicDoubleLinkedNode

public BasicDoubleLinkedNode()
The constructor.

Method Detail

getPrevious

public BasicDoubleLinkedNode<V> getPrevious()
This method gets the previous node of the double linked list.

Specified by:
getPrevious in interface DoubleLinkedNode<V,BasicDoubleLinkedNode<V>>
Returns:
the previous node or null if this is the first node (head).

setPrevious

public void setPrevious(BasicDoubleLinkedNode<V> previous)
This method sets the previous node.

Parameters:
previous - is the previous node to set. May be null to indicate that this is the first node of the list.

insertAsNext

public BasicDoubleLinkedNode<V> insertAsNext(V value,
                                             boolean overrideNullValue)
This method inserts the given value into the list at the position represented by this node. It will typically create a new node containing the given value and set it as next. It will guarantee the following equation:
this.AbstractLinkedNode.getNext().getPrevious() == this
If overrideNullValue is true and the value of this node is null, then its value is set to the given value instead of creating a new node.

Parameters:
value - is the value to insert.
overrideNullValue - - true if a value of null should be replaced with the given value, false otherwise.
Returns:
the node containing the given value.

insertAsNext

public void insertAsNext(BasicDoubleLinkedNode<V> node)
This method inserts the given node into the list immediately after the position represented by this node.

Parameters:
node - is the node to add.

insertAsPrevious

public void insertAsPrevious(BasicDoubleLinkedNode<V> node)
This method inserts the given node into the list immediately before the position represented by this node.

Parameters:
node - is the node to add.

insertAsPrevious

public BasicDoubleLinkedNode<V> insertAsPrevious(V value,
                                                 boolean overrideNullValue)
This method inserts the given value into the list at the position represented by this node. It will typically create a new node containing the given value and set it as next. It will guarantee the following equation:
this.AbstractLinkedNode.getNext().getPrevious() == this
If overrideNullValue is true and the value of this node is null, then its value is set to the given value instead of creating a new node.

Parameters:
value - is the value to insert.
overrideNullValue - - true if a value of null should be replaced with the given value, false otherwise.
Returns:
the node containing the given value.

remove

public void remove()
This method removes this node from the double linked list.


isLinked

public boolean isLinked()
This method determines if this node is linked. A node is linked if it has a next node.

Specified by:
isLinked in interface DoubleLinkedNode<V,BasicDoubleLinkedNode<V>>
Specified by:
isLinked in interface LinkedNode<V,BasicDoubleLinkedNode<V>>
Overrides:
isLinked in class AbstractLinkedNode<V,BasicDoubleLinkedNode<V>>
Returns:
true if linked, false otherwise.


Copyright © 2001-2010 mmm-Team. All Rights Reserved.