1 /******************************************************************************* 2 * Copyright (c) 2000, 2005 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; 12 13 /** 14 * Common interface for objects with editable contents. 15 * Typically it is implemented by objects that also implement 16 * the <code>IStreamContentAccessor</code> interface. 17 * <p> 18 * Clients may implement this interface. 19 * <p> 20 * Note that implementing <code>IEditableContent</code> does not 21 * automatically mean that it is editable. An object is only editable if 22 * it implements <code>IEditableContent</code> and the <code>isEditable</code> method returns <code>true</code>. 23 * 24 * @see IStreamContentAccessor 25 */ 26 public interface IEditableContent { 27 28 /** 29 * Returns <code>true</code> if this object can be modified. 30 * If it returns <code>false</code> the other methods of this API must not be called. 31 * 32 * @return <code>true</code> if this object can be modified 33 */ 34 boolean isEditable(); 35 36 /** 37 * Replaces the current content with the given new bytes. 38 * 39 * @param newContent this new contents replaces the old contents 40 */ 41 void setContent(byte[] newContent); 42 43 /** 44 * This method is called on a parent to add or remove a child, 45 * or to copy the contents of a child. 46 * 47 * What to do is encoded in the two arguments as follows: 48 * <TABLE> 49 * <TR> 50 * <TD>add:</TD> 51 * <TD>dest == null</TD> 52 * <TD>src != null</TD> 53 * </TR> 54 * <TR> 55 * <TD>remove:</TD> 56 * <TD>dest != null</TD> 57 * <TD>src == null</TD> 58 * </TR> 59 * <TR> 60 * <TD>copy:</TD> 61 * <TD>dest != null</TD> 62 * <TD>src != null</TD> 63 * </TR> 64 * </TABLE> 65 * @param dest the existing child of this object to be replaced; if <code>null</code> a new child can be added. 66 * @param src the new child to be added or replaced; if <code>null</code> an existing child can be removed. 67 * @return the argument <code>dest</code> 68 */ 69 ITypedElement replace(ITypedElement dest, ITypedElement src); 70 } 71