KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > internal > databinding > provisional > observable > value > ValueDiff


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.value;
13
14 import org.eclipse.jface.internal.databinding.provisional.observable.Diffs;
15 import org.eclipse.jface.internal.databinding.provisional.observable.IDiff;
16
17 /**
18  * @since 1.0
19  *
20  */

21 public abstract class ValueDiff implements IDiff {
22
23     /**
24      * Creates a value diff.
25      */

26     public ValueDiff() {
27     }
28
29     /**
30      * @return the old value
31      */

32     public abstract Object JavaDoc getOldValue();
33
34     /**
35      * @return the new value
36      */

37     public abstract Object JavaDoc getNewValue();
38
39     public boolean equals(Object JavaDoc obj) {
40         if (obj instanceof ValueDiff) {
41             ValueDiff val = (ValueDiff) obj;
42
43             return Diffs.equals(val.getNewValue(), getNewValue())
44                     && Diffs.equals(val.getOldValue(), getOldValue());
45
46         }
47         return false;
48     }
49     
50     /**
51      * @see java.lang.Object#toString()
52      */

53     public String JavaDoc toString() {
54         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
55         buffer
56             .append(getClass().getName())
57             .append("{oldValue [") //$NON-NLS-1$
58
.append(getOldValue() != null ? getOldValue().toString() : "null") //$NON-NLS-1$
59
.append("], newValue [") //$NON-NLS-1$
60
.append(getNewValue() != null ? getNewValue().toString() : "null") //$NON-NLS-1$
61
.append("]}"); //$NON-NLS-1$
62

63         return buffer.toString();
64     }
65 }
66
Popular Tags