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 ordered collections. It is stored
20: * in the new State when changes to an ordered collection field are persisted.
21: */
22: public class OrderedCollectionDiff extends CollectionDiff {
23:
24: public OrderedCollectionDiff() {
25: }
26:
27: public OrderedCollectionDiff(VersantFieldMetaData fmd) {
28: super (fmd);
29: }
30:
31: /**
32: * The indexes of all deleted values. These must be in ascending order.
33: */
34: public int[] deletedIndexes;
35:
36: /**
37: * The indexes of all inserted values. This array will be the same size
38: * as insertedValues. These must be in ascending order.
39: */
40: public int[] insertedIndexes;
41:
42: public String toString() {
43: return "<OrderedCollectionDiff inserted = "
44: + (insertedIndexes != null ? insertedIndexes.length : 0)
45: + " deleted = "
46: + (deletedIndexes != null ? deletedIndexes.length : 0);
47: }
48:
49: public void writeExternal(OIDObjectOutput out) throws IOException {
50: super .writeExternal(out);
51: SerUtils.writeIntArray(deletedIndexes, out);
52: SerUtils.writeIntArray(insertedIndexes, out);
53: }
54:
55: public void readExternal(OIDObjectInput in) throws IOException,
56: ClassNotFoundException {
57: super.readExternal(in);
58: deletedIndexes = SerUtils.readIntArray(in);
59: insertedIndexes = SerUtils.readIntArray(in);
60: }
61:
62: }
|