01: /*
02: * Copyright (c) 1998 - 2005 Versant Corporation
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Versant Corporation - initial API and implementation
10: */
11: package com.versant.core.common;
12:
13: import com.versant.core.util.OIDObjectOutput;
14: import com.versant.core.util.OIDObjectInput;
15:
16: import java.io.IOException;
17:
18: /**
19: * This holds the differences between two maps. It is stored in the new State
20: * when changes to a map field are persisted.
21: */
22: public class MapDiff extends CollectionDiff {
23:
24: public MapDiff() {
25: }
26:
27: public MapDiff(VersantFieldMetaData fmd) {
28: super (fmd);
29: }
30:
31: /**
32: * The deleted keys.
33: */
34: public Object[] deletedKeys;
35:
36: /**
37: * The inserted keys. This array will be the same size as insertedValues.
38: * The value for each key is the element of insertedValues at the same
39: * index.
40: */
41: public Object[] insertedKeys;
42:
43: public void writeExternal(OIDObjectOutput out) throws IOException {
44: super .writeExternal(out);
45: write(out, fmd.getKeyTypeCode(), fmd.isKeyTypePC(), deletedKeys);
46: write(out, fmd.getKeyTypeCode(), fmd.isKeyTypePC(),
47: insertedKeys);
48: }
49:
50: public void readExternal(OIDObjectInput in) throws IOException,
51: ClassNotFoundException {
52: super.readExternal(in);
53: deletedKeys = read(in, fmd.getKeyTypeCode(), fmd.isKeyTypePC());
54: insertedKeys = read(in, fmd.getKeyTypeCode(), fmd.isKeyTypePC());
55: }
56:
57: }
|