KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > databinding > observable > list > ListDiff


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 package org.eclipse.core.databinding.observable.list;
13
14
15 /**
16  * Object describing a diff between two lists.
17  *
18  * @since 1.0
19  */

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

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

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

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

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