001    /*
002     * This file is part of the Echo Point Project.  This project is a
003     * collection of Components that have extended the Echo Web Application
004     * Framework Version 3.
005     *
006     * Version: MPL 1.1
007     *
008     * The contents of this file are subject to the Mozilla Public License Version
009     * 1.1 (the "License"); you may not use this file except in compliance with
010     * the License. You may obtain a copy of the License at
011     * http://www.mozilla.org/MPL/
012     *
013     * Software distributed under the License is distributed on an "AS IS" basis,
014     * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
015     * for the specific language governing rights and limitations under the
016     * License.
017     */
018    
019    package echopoint.tree;
020    
021    /**
022     * Defines the requirements for a tree node object that can change -- by
023     * adding or removing child nodes, or by changing the contents of a user
024     * object stored in the node.
025     *
026     * @param <M> The user object backing the node.
027     * @author Brad Baker, Rakesh Vidyadharan 2009-05-29
028     * @version $Id: MutableTreeNode.java 213 2009-06-03 16:34:13Z sptrakesh $
029     * @since 3.0.0b3
030     */
031    public interface MutableTreeNode<M> extends TreeNode
032    {
033      /**
034       * Adds {@code child} to the receiver at {@code index}.
035       * {@code child} will be messaged with {@link #setParent}.
036       *
037       * @param child The child to add.
038       * @param index The index at which to add the child.
039       */
040      void insert( final MutableTreeNode child, final int index );
041    
042      /**
043       * Removes the child at {@code index} from the receiver.  {@link #setParent}
044       * will be messaged on the node being removed.
045       *
046       * @param index The index of the child to remove.
047       */
048      void remove( final int index );
049    
050      /**
051       * Removes {@code node} from the receiver. {@link #setParent} will
052       * be messaged on {@code node}.
053       *
054       * @param node The node to remove.
055       */
056      void remove( final MutableTreeNode node );
057    
058      /** Removes the receiver from its parent. */
059      void removeFromParent();
060    
061      /**
062       * Sets the parent of the receiver to {@code newParent}.
063       *
064       * @param newParent The new parent for the node.
065       */
066      void setParent( final MutableTreeNode newParent );
067    
068      /**
069       * Resets the user object of the receiver to {@code object}.
070       *
071       * @param object The user object of the receiver
072       */
073      void setUserObject( final M object );
074    }