1 46 47 package org.mr.core.net; 48 49 import java.io.IOException ; 50 51 import org.mr.core.util.byteable.Byteable; 52 import org.mr.core.util.byteable.ByteableInputStream; 53 import org.mr.core.util.byteable.ByteableOutputStream; 54 import org.mr.core.util.byteable.ByteableRegistry; 55 56 65 public class SimpleMantaAddress implements MantaAddress { 66 private String name; 67 private String domain; 68 69 public SimpleMantaAddress(String name, String domain) { 70 this.name = name; 71 this.domain = domain; 72 } 73 74 public SimpleMantaAddress() { 75 } 76 77 public String getAgentName() { 78 return this.name; 79 } 80 81 public void setAgentName(String name) { 82 this.name = name; 83 } 84 85 public String getDomainName() { 86 return this.domain; 87 } 88 89 public void setDomainName(String domain) { 90 this.domain = domain; 91 } 92 93 public String getByteableName() { 95 return "org.mr.core.net.SimpleMantaAddress"; 96 } 97 98 public void toBytes(ByteableOutputStream out) throws IOException { 99 out.writeASCIIString(this.name); 100 out.writeASCIIString(this.domain); 101 } 102 103 public Byteable createInstance(ByteableInputStream in) throws IOException { 104 SimpleMantaAddress result = new SimpleMantaAddress(); 105 result.setAgentName(in.readASCIIString()); 106 result.setDomainName(in.readASCIIString()); 107 return result; 108 } 109 110 public void registerToByteableRegistry() { 111 ByteableRegistry.registerByteableFactory(getByteableName(), this); 112 } 113 114 public static void register() { 115 SimpleMantaAddress instance = new SimpleMantaAddress(); 116 instance.registerToByteableRegistry(); 117 } 118 119 public String toString() { 120 return "Simple:" + name; 121 } 122 } 123 | Popular Tags |