KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > MergeView


1 // $Id: MergeView.java,v 1.2 2004/09/15 17:41:03 belaban Exp $
2

3
4 package org.jgroups;
5
6 import java.io.IOException JavaDoc;
7 import java.io.ObjectInput JavaDoc;
8 import java.io.ObjectOutput JavaDoc;
9 import java.util.Vector JavaDoc;
10
11
12 /**
13  * A view that is sent as result of a merge.
14  */

15 public class MergeView extends View {
16     protected Vector JavaDoc subgroups=null; // subgroups that merged into this single view (a list of Views)
17

18
19     /**
20      * Used by externalization
21      */

22     public MergeView() {
23     }
24
25
26     /**
27      * Creates a new view
28      *
29      * @param vid The view id of this view (can not be null)
30      * @param members Contains a list of all the members in the view, can be empty but not null.
31      * @param subgroups A list of Views representing the former subgroups
32      */

33     public MergeView(ViewId vid, Vector JavaDoc members, Vector JavaDoc subgroups) {
34         super(vid, members);
35         this.subgroups=subgroups;
36     }
37
38
39     /**
40      * Creates a new view
41      *
42      * @param creator The creator of this view (can not be null)
43      * @param id The lamport timestamp of this view
44      * @param members Contains a list of all the members in the view, can be empty but not null.
45      * @param subgroups A list of Views representing the former subgroups
46      */

47     public MergeView(Address creator, long id, Vector JavaDoc members, Vector JavaDoc subgroups) {
48         super(creator, id, members);
49         this.subgroups=subgroups;
50     }
51
52
53     public Vector JavaDoc getSubgroups() {
54         return subgroups;
55     }
56
57
58     /**
59      * creates a copy of this view
60      *
61      * @return a copy of this view
62      */

63     public Object JavaDoc clone() {
64         ViewId vid2=vid != null ? (ViewId)vid.clone() : null;
65         Vector JavaDoc members2=members != null ? (Vector JavaDoc)members.clone() : null;
66         Vector JavaDoc subgroups2=subgroups != null ? (Vector JavaDoc)subgroups.clone() : null;
67         return new MergeView(vid2, members2, subgroups2);
68     }
69
70
71     public String JavaDoc toString() {
72         StringBuffer JavaDoc sb=new StringBuffer JavaDoc();
73         sb.append("MergeView::" + super.toString());
74         sb.append(", subgroups=" + subgroups);
75         return sb.toString();
76     }
77
78
79     public void writeExternal(ObjectOutput JavaDoc out) throws IOException JavaDoc {
80         super.writeExternal(out);
81         out.writeObject(subgroups);
82     }
83
84
85     public void readExternal(ObjectInput JavaDoc in) throws IOException JavaDoc, ClassNotFoundException JavaDoc {
86         super.readExternal(in);
87         subgroups=(Vector JavaDoc)in.readObject();
88     }
89
90
91 }
92
Popular Tags