comparison org.eclipse.core.databinding/src/org/eclipse/core/internal/databinding/observable/tree/TreeDiffNode.d @ 78:0a55d2d5a946

Added file for databinding
author Frank Benoit <benoit@tionex.de>
date Tue, 14 Apr 2009 11:35:29 +0200
parents
children 383ce7bd736b
comparison
equal deleted inserted replaced
76:f05e6e8b2f2d 78:0a55d2d5a946
1 /*******************************************************************************
2 * Copyright (c) 2006, 2007 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
12 module org.eclipse.core.internal.databinding.observable.tree.TreeDiffNode;
13
14 import java.lang.all;
15
16 /**
17 * @since 1.1
18 *
19 */
20 public abstract class TreeDiffNode {
21
22 /**
23 *
24 */
25 public final static int NO_CHANGE = 0x00;
26
27 /**
28 *
29 */
30 public final static int ADDED = 0x01;
31
32 /**
33 *
34 */
35 public final static int REMOVED = 0x02;
36
37 /**
38 *
39 */
40 public final static int REPLACED = 0x03;
41
42 /**
43 *
44 */
45 public static final TreeDiffNode[] NO_CHILDREN = new TreeDiffNode[0];
46
47 /**
48 *
49 */
50 public static final int INDEX_UNKNOWN = -1;
51
52 /**
53 * @return the change type
54 */
55 public abstract int getChangeType();
56
57 /**
58 * @return the element that was removed, or the replaced element
59 */
60 public abstract Object getOldElement();
61
62 /**
63 * @return the element that was not changed, added, or the replacement
64 * element
65 */
66 public abstract Object getNewElement();
67
68 /**
69 * @return the index at which the element was added, removed, or replaced
70 */
71 public abstract int getIndex();
72
73 /**
74 * Returns the child tree diff objects that describe changes to children. If
75 * the change type is REMOVED, there will be no children.
76 *
77 * @return the nodes representing changes to children
78 */
79 public abstract TreeDiffNode[] getChildren();
80
81 protected void doAccept(TreeDiffVisitor visitor, TreePath parentPath) {
82 TreePath currentPath = parentPath.createChildPath(getNewElement());
83 bool recurse = visitor.visit(this, currentPath);
84 if (recurse) {
85 TreeDiffNode[] children = getChildren();
86 for (int i = 0; i < children.length; i++) {
87 TreeDiffNode child = children[i];
88 child.doAccept(visitor, currentPath);
89 }
90 }
91 }
92
93 }