KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > internal > databinding > provisional > observable > list > ListDiff


1 /*******************************************************************************
2  * Copyright (c) 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
12 package org.eclipse.jface.internal.databinding.provisional.observable.list;
13
14 import org.eclipse.jface.internal.databinding.provisional.observable.IDiff;
15
16 /**
17  * Object describing a diff between two lists.
18  *
19  * @since 1.0
20  */

21 public abstract class ListDiff implements IDiff {
22
23     /**
24      * Returns a list of ListDiffEntry
25      *
26      * @return a list of ListDiffEntry
27      */

28     public abstract ListDiffEntry[] getDifferences();
29     
30     /**
31      * @see java.lang.Object#toString()
32      */

33     public String JavaDoc toString() {
34         ListDiffEntry[] differences = getDifferences();
35         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
36         buffer.append(getClass().getName());
37         
38         if (differences == null || differences.length == 0) {
39             buffer
40                 .append("{}"); //$NON-NLS-1$
41
} else {
42             buffer
43                 .append("{"); //$NON-NLS-1$
44

45             for (int i = 0; i < differences.length; i++) {
46                 if (i > 0)
47                     buffer.append(", "); //$NON-NLS-1$
48

49                 buffer
50                     .append("difference[") //$NON-NLS-1$
51
.append(i)
52                     .append("] [") //$NON-NLS-1$
53
.append(differences[i] != null ? differences[i].toString() : "null") //$NON-NLS-1$
54
.append("]"); //$NON-NLS-1$
55
}
56             buffer.append("}"); //$NON-NLS-1$
57
}
58         
59         return buffer.toString();
60     }
61 }
62
Popular Tags