Skip to main content
summaryrefslogtreecommitdiffstats
blob: a972a0a7da8ddb32643f3a52b4349af774df9be2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*******************************************************************************
 * Copyright (c) 2000, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.compare;

/**
 * Common interface for objects with editable contents.
 * Typically it is implemented by objects that also implement
 * the <code>IStreamContentAccessor</code> interface.
 * <p>
 * Clients may implement this interface.
 * <p>
 * Note that implementing <code>IEditableContent</code> does not
 * automatically mean that it is editable. An object is only editable if
 * it implements <code>IEditableContent</code> and the <code>isEditable</code> method returns <code>true</code>.
 *
 * @see IStreamContentAccessor
 */
public interface IEditableContent {
	
	/**
	 * Returns <code>true</code> if this object can be modified.
	 * If it returns <code>false</code> the other methods of this API must not be called.
	 * 
	 * @return <code>true</code> if this object can be modified
	 */
	boolean isEditable();
			
	/**
	 * Replaces the current content with the given new bytes.
	 * 
	 * @param newContent this new contents replaces the old contents
	 */
	void setContent(byte[] newContent); 

	/**
	 * This method is called on a parent to add or remove a child,
	 * or to copy the contents of a child.
	 * 
	 * What to do is encoded in the two arguments as follows:
	 * <TABLE>
	 * <TR>
	 * 	<TD>add:</TD>
	 *  <TD>child == null</TD>
	 *  <TD>other != null</TD>
	 * </TR>
	 * <TR>
	 * 	<TD>remove:</TD>
	 *  <TD>child != null</TD>
	 *  <TD>other == null</TD>
	 * </TR>
	 * <TR>
	 * 	<TD>copy:</TD>
	 *  <TD>child != null</TD>
	 *  <TD>other != null</TD>
	 * </TR>
	 * </TABLE>
	 */
	ITypedElement replace(ITypedElement child, ITypedElement other);
}

Back to the top