Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 46 50 package org.mr.core.util.byteable; 51 52 import java.io.IOException ; 53 import java.util.ArrayList ; 54 import java.util.List ; 55 56 57 65 public class ByteableList extends ArrayList implements Byteable { 66 67 public ByteableList(){ 68 super(); 69 } 70 71 public ByteableList(List list){ 72 super(list); 73 } 74 75 76 public ByteableList(int initSize){ 77 super(initSize); 78 } 79 80 83 public String getByteableName() { 84 return "BList"; 85 } 86 87 90 public void toBytes(ByteableOutputStream out) throws IOException { 91 int size = this.size(); 92 out.writeInt(size); 93 for (int i = 0; i < size; i++) { 94 out.writeByteable((Byteable)this.get(i)); 95 } 96 97 } 98 99 102 public Byteable createInstance(ByteableInputStream in) throws IOException { 103 int size = in.readInt(); 104 ByteableList result = new ByteableList(size); 105 for (int i = 0; i < size; i++) { 106 result.add(in.readByteable()); 107 } 108 return result; 109 } 110 111 114 public void registerToByteableRegistry() { 115 ByteableRegistry.registerByteableFactory(getByteableName() , this); 116 } 117 118 119 public static void register(){ 120 ByteableList instance = new ByteableList(); 121 instance.registerToByteableRegistry(); 122 } 123 124 public String toString(){ 125 return super.toString(); 126 } 127 128 129 } 130
| Popular Tags
|