1 46 47 package org.mr.indexing.messages; 48 49 import java.io.IOException ; 50 import java.util.ArrayList ; 51 import java.util.List ; 52 import java.util.Set ; 53 import java.util.Iterator ; 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 71 public class AgentTransportsChanged implements Byteable { 72 private final static String typeString = "AgentTransportsChanged"; 73 74 String agentName; 75 String domainName; 76 ByteableList addedTransports; 77 ByteableList removedTransports; 78 boolean cleanAll; 79 80 86 public String getAgentName() { 87 return this.agentName; 88 } 89 90 public String getDomainName() { 91 return this.domainName; 92 } 93 94 public List getAddedTransports() { 95 return this.addedTransports; 96 } 97 98 public List getRemovedTransports() { 99 return this.removedTransports; 100 } 101 102 public boolean getCleanAll() { 103 return this.cleanAll; 104 } 105 106 public void setAgentName(String agentName) { 107 this.agentName = agentName; 108 } 109 110 public void setDomainName(String domainName) { 111 this.domainName = domainName; 112 } 113 114 public void setAddedTransports(Set transports) { 115 this.addedTransports = new ByteableList(new ArrayList (transports)); 116 } 117 118 public void setRemovedTransports(Set transports) { 119 this.removedTransports = new ByteableList(new ArrayList (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 getByteableName() { 135 return "org.mr.indexing.messages.AgentTransportsChanged"; 136 } 137 138 public void toBytes(ByteableOutputStream out) throws IOException { 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 { 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 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 detailedToString() { 182 Iterator i; 183 StringBuffer retval = new StringBuffer (); 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 getTypeString() { 203 return typeString; 204 } 205 } | Popular Tags |