KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > versant > core > common > OrderedCollectionDiff


1
2 /*
3  * Copyright (c) 1998 - 2005 Versant Corporation
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  * Versant Corporation - initial API and implementation
11  */

12 package com.versant.core.common;
13
14 import com.versant.core.util.OIDObjectOutput;
15 import com.versant.core.util.OIDObjectInput;
16
17 import java.io.IOException JavaDoc;
18
19 /**
20  * This holds the differences between two ordered collections. It is stored
21  * in the new State when changes to an ordered collection field are persisted.
22  */

23 public class OrderedCollectionDiff extends CollectionDiff {
24
25     public OrderedCollectionDiff() {
26     }
27
28     public OrderedCollectionDiff(VersantFieldMetaData fmd) {
29         super(fmd);
30     }
31
32     /**
33      * The indexes of all deleted values. These must be in ascending order.
34      */

35     public int[] deletedIndexes;
36
37     /**
38      * The indexes of all inserted values. This array will be the same size
39      * as insertedValues. These must be in ascending order.
40      */

41     public int[] insertedIndexes;
42
43     public String JavaDoc toString() {
44         return "<OrderedCollectionDiff inserted = " + (insertedIndexes != null ? insertedIndexes.length : 0)
45                 + " deleted = " + (deletedIndexes != null ? deletedIndexes.length : 0);
46     }
47
48     public void writeExternal(OIDObjectOutput out) throws IOException JavaDoc {
49         super.writeExternal(out);
50         SerUtils.writeIntArray(deletedIndexes, out);
51         SerUtils.writeIntArray(insertedIndexes, out);
52     }
53
54     public void readExternal(OIDObjectInput in) throws IOException JavaDoc,
55             ClassNotFoundException JavaDoc {
56         super.readExternal(in);
57         deletedIndexes = SerUtils.readIntArray(in);
58         insertedIndexes = SerUtils.readIntArray(in);
59     }
60
61 }
62
Popular Tags