KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mr > indexing > messages > AgentTransportsChanged


1 /*
2  * Copyright 2002 by
3  * <a HREF="http://www.coridan.com">Coridan</a>
4  * <a HREF="mailto: support@coridan.com ">support@coridan.com</a>
5  *
6  * The contents of this file are subject to the Mozilla Public License Version
7  * 1.1 (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  * http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is "MantaRay" (TM).
17  *
18  * The Initial Developer of the Original Code is Uri Schneider.
19  * Portions created by the Initial Developer are Copyright (C) 2006
20  * Coridan Inc. All Rights Reserved.
21  *
22  * Contributor(s): all the names of the contributors are added in the source
23  * code where applicable.
24  *
25  * Alternatively, the contents of this file may be used under the terms of the
26  * LGPL license (the "GNU LESSER GENERAL PUBLIC LICENSE"), in which case the
27  * provisions of LGPL are applicable instead of those above. If you wish to
28  * allow use of your version of this file only under the terms of the LGPL
29  * License and not to allow others to use your version of this file under
30  * the MPL, indicate your decision by deleting the provisions above and
31  * replace them with the notice and other provisions required by the LGPL.
32  * If you do not delete the provisions above, a recipient may use your version
33  * of this file under either the MPL or the GNU LESSER GENERAL PUBLIC LICENSE.
34  
35  *
36  * This library is free software; you can redistribute it and/or modify it
37  * under the terms of the MPL as stated above or under the terms of the GNU
38  * Lesser General Public License as published by the Free Software Foundation;
39  * either version 2.1 of the License, or any later version.
40  *
41  * This library is distributed in the hope that it will be useful, but WITHOUT
42  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
43  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
44  * License for more details.
45  */

46
47 package org.mr.indexing.messages;
48
49 import java.io.IOException JavaDoc;
50 import java.util.ArrayList JavaDoc;
51 import java.util.List JavaDoc;
52 import java.util.Set JavaDoc;
53 import java.util.Iterator JavaDoc;
54
55 import org.mr.core.util.byteable.Byteable;
56 import org.mr.core.util.byteable.ByteableInputStream;
57 import org.mr.core.util.byteable.ByteableList;
58 import org.mr.core.util.byteable.ByteableOutputStream;
59 import org.mr.core.util.byteable.ByteableRegistry;
60
61
62 /**
63  * AgentTransportsChanged.java
64  *
65  *
66  * Created: Mon Dec 06 17:29:35 2004
67  *
68  * @author Uri Schneider
69  * @version 1.0
70  */

71 public class AgentTransportsChanged implements Byteable {
72     private final static String JavaDoc typeString = "AgentTransportsChanged";
73
74     String JavaDoc agentName;
75     String JavaDoc domainName;
76     ByteableList addedTransports;
77     ByteableList removedTransports;
78     boolean cleanAll;
79
80 // public AgentTransportsChanged() {
81
// this.agentName = "";
82
// this.addedTransports = new ByteableList();
83
// this.removedTransports = new ByteableList();
84
// } // AgentTransportsChanged constructor
85

86     public String JavaDoc getAgentName() {
87         return this.agentName;
88     }
89
90     public String JavaDoc getDomainName() {
91         return this.domainName;
92     }
93
94     public List JavaDoc getAddedTransports() {
95         return this.addedTransports;
96     }
97
98     public List JavaDoc getRemovedTransports() {
99         return this.removedTransports;
100     }
101
102     public boolean getCleanAll() {
103         return this.cleanAll;
104     }
105
106     public void setAgentName(String JavaDoc agentName) {
107         this.agentName = agentName;
108     }
109
110     public void setDomainName(String JavaDoc domainName) {
111         this.domainName = domainName;
112     }
113
114     public void setAddedTransports(Set JavaDoc transports) {
115         this.addedTransports = new ByteableList(new ArrayList JavaDoc(transports));
116     }
117
118     public void setRemovedTransports(Set JavaDoc transports) {
119         this.removedTransports = new ByteableList(new ArrayList JavaDoc(transports));
120     }
121
122     public void setAddedTransports(ByteableList transports) {
123         this.addedTransports = transports;
124     }
125
126     public void setRemovedTransports(ByteableList transports) {
127         this.removedTransports = transports;
128     }
129
130     public void setCleanAll(boolean cleanAll) {
131         this.cleanAll = cleanAll;
132     }
133
134     public String JavaDoc getByteableName() {
135         return "org.mr.indexing.messages.AgentTransportsChanged";
136     }
137
138     public void toBytes(ByteableOutputStream out) throws IOException JavaDoc {
139         if (this.addedTransports == null) {
140             this.addedTransports = new ByteableList();
141         }
142         if (this.removedTransports == null) {
143             this.removedTransports = new ByteableList();
144         }
145         out.writeASCIIString(this.agentName);
146         out.writeASCIIString(this.domainName);
147         out.writeByteable(this.addedTransports);
148         out.writeByteable(this.removedTransports);
149         out.writeBoolean(this.cleanAll);
150     }
151
152     public Byteable createInstance(ByteableInputStream in) throws IOException JavaDoc {
153         AgentTransportsChanged result = new AgentTransportsChanged();
154         result.setAgentName(in.readASCIIString());
155         result.setDomainName(in.readASCIIString());
156         result.setAddedTransports((ByteableList) in.readByteable());
157         result.setRemovedTransports((ByteableList) in.readByteable());
158         result.setCleanAll(in.readBoolean());
159         return result;
160     }
161
162     public void registerToByteableRegistry() {
163         ByteableRegistry.registerByteableFactory(getByteableName(), this);
164     }
165
166     public static void register() {
167         AgentTransportsChanged instance =
168             new AgentTransportsChanged();
169         instance.registerToByteableRegistry();
170     }
171
172     public String JavaDoc toString() {
173         return "MWB:ATC " +
174             (agentName == null ? "null" : agentName) + " [" +
175             (addedTransports == null ? 0 : addedTransports.size()) +
176             " added/" +
177             (removedTransports == null ? 0 : removedTransports.size()) +
178             " removed]";
179     }
180
181     public String JavaDoc detailedToString() {
182         Iterator JavaDoc i;
183         StringBuffer JavaDoc retval = new StringBuffer JavaDoc();
184         retval.append("MWB:ATC ")
185             .append((agentName == null ? "null" : agentName)).append(":");
186         if (addedTransports != null) {
187             i = addedTransports.iterator();
188             while (i.hasNext()) {
189                 retval.append(" ").append(i.next()).append("A");
190             }
191         }
192         if (removedTransports != null) {
193             i = removedTransports.iterator();
194             while (i.hasNext()) {
195                 retval.append(" ").append(i.next()).append("R");
196             }
197         }
198
199         return retval.toString();
200     }
201
202     public static final String JavaDoc getTypeString() {
203         return typeString;
204     }
205 } // AgentTransportsChanged
206
Popular Tags