1 /******************************************************************************* 2 * Copyright (c) 2000, 2006 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.compare.structuremergeviewer; 12 13 /** 14 * <code>IDiffContainer</code> is a <code>IDiffElement</code> with children. 15 * <p> 16 * <code>IDiffContainer</code> are the inner nodes displayed 17 * by the <code>DiffTreeViewer</code>. 18 * <code>IDiffContainer</code> are typically created as the result of performing 19 * a compare with the <code>Differencer</code>. 20 * <p> 21 * Clients may implement this interface, or use one of the standard implementations, 22 * <code>DiffContainer</code> or <code>DiffNode</code>. 23 * 24 * @see Differencer 25 * @see DiffTreeViewer 26 */ 27 public interface IDiffContainer extends IDiffElement { 28 29 /** 30 * Returns whether this container has at least one child. 31 * In some cases this methods avoids having to call the 32 * potential more costly <code>getChildren</code> method. 33 * 34 * @return <code>true</code> if this container has at least one child 35 */ 36 boolean hasChildren(); 37 38 /** 39 * Returns the children of this container. 40 * If this container has no children an empty array is returned (not <code>null</code>). 41 * 42 * @return the children of this container as an array 43 */ 44 IDiffElement[] getChildren(); 45 46 /** 47 * Adds the given child to this container. 48 * If the child is already contained in this container, this method has no effect. 49 * 50 * @param child the child to be added to this container 51 */ 52 void add(IDiffElement child); 53 54 /** 55 * Removes the given child from this container. 56 * If the container becomes empty it is removed from its container. 57 * If the child is not contained in this container, this method has no effect. 58 * 59 * @param child the child to be removed from this container 60 */ 61 void removeToRoot(IDiffElement child); 62 } 63