package hep.aida.ref.tree;

import hep.aida.IManagedObject;
import hep.aida.ref.event.AIDAListener;
import hep.aida.ref.event.TreeEvent;

/**
 * A mount point allows one tree to be "mounted" in another.
 * Mount point extends Folder so that it appears as just another folder
 * to the tree, but it overrides all of Folders methods and forwards
 * them to the mountPoint within the mounted tree.
 * @author tonyj
 * @version $Id: MountPoint.java 8584 2006-08-10 23:06:37Z duns $
 */
public class MountPoint extends Folder implements AIDAListener {
    private Folder mountPoint;
    private Tree tree;
    private Tree source;
    private boolean isUnmounted = false;
    
    int mountDepth;
    String[] prefix;
    
    MountPoint(Tree source, Path prefix, Tree tree, Folder mountPoint, Path mountPath) {
        super(prefix.getName());
        this.tree = tree;
        this.mountPoint = mountPoint;
        this.source = source;
        this.prefix = prefix.toArray();
        this.mountDepth = mountPath.size();
        tree.addListener(this);
    }
    public void stateChanged(java.util.EventObject e) {
        if ( ! isUnmounted ) {
            TreeEvent te = (TreeEvent) e;
            String [] oldPath = te.getPath();
            int newDepth = oldPath.length - mountDepth + prefix.length;
            String[] newPath = new String[newDepth];
            int i=0;
            for (; i 

Ads help maintain this website.