Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 3285 invoked from network); 22 Feb 2002 03:18:00 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 22 Feb 2002 03:18:00 -0000 Received: (qmail 3264 invoked by uid 97); 22 Feb 2002 03:18:06 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 3245 invoked by uid 97); 22 Feb 2002 03:18:06 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 3234 invoked by uid 97); 22 Feb 2002 03:18:05 -0000 Date: 22 Feb 2002 03:17:40 -0000 Message-ID: <20020222031740.19125.qmail@icarus.apache.org> From: mas@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections SequencedHashMap.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N mas 02/02/21 19:17:40 Modified: collections/src/java/org/apache/commons/collections SequencedHashMap.java Log: Implement Externalizable in SequencedHashMap Revision Changes Path 1.7 +34 -4 jakarta-commons/collections/src/java/org/apache/commons/collections/SequencedHashMap.java Index: SequencedHashMap.java =================================================================== RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/SequencedHashMap.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- SequencedHashMap.java 22 Feb 2002 02:37:56 -0000 1.6 +++ SequencedHashMap.java 22 Feb 2002 03:17:40 -0000 1.7 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/SequencedHashMap.java,v 1.6 2002/02/22 02:37:56 mas Exp $ - * $Revision: 1.6 $ - * $Date: 2002/02/22 02:37:56 $ + * $Header: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/SequencedHashMap.java,v 1.7 2002/02/22 03:17:40 mas Exp $ + * $Revision: 1.7 $ + * $Date: 2002/02/22 03:17:40 $ * * ==================================================================== * @@ -60,6 +60,11 @@ */ package org.apache.commons.collections; +import java.io.Externalizable; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.io.IOException; + import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -91,7 +96,7 @@ * @author Daniel Rall * @author Henning P. Schmiedehausen */ -public class SequencedHashMap implements Map, Cloneable { +public class SequencedHashMap implements Map, Cloneable, Externalizable { /** * {@link java.util.Map.Entry} that doubles as a node in the linked list @@ -878,5 +883,30 @@ { return remove(get(index)); } + + // per Externalizable.readExternal(ObjectInput) + public void readExternal( ObjectInput in ) + throws IOException, ClassNotFoundException + { + int size = in.readInt(); + for(int i = 0; i < size; i++) { + Object key = in.readObject(); + Object value = in.readObject(); + put(key, value); + } + } + + // per Externalizable.writeExternal(ObjectOutput) + public void writeExternal( ObjectOutput out ) throws IOException { + out.writeInt(size()); + for(Entry pos = sentinel.next; pos != sentinel; pos = pos.next) { + out.writeObject(pos.getKey()); + out.writeObject(pos.getValue()); + } + } + + // add a serial version uid, so that if we change things in the future + // without changing the format, we can still deserialize properly. + private static final long serialVersionUID = 3380552487888102930L; } -- To unsubscribe, e-mail: For additional commands, e-mail: