1 package com.quadcap.sql.io; 2 3 40 41 import java.io.IOException ; 42 import java.io.ObjectInput ; 43 import java.io.ObjectOutput ; 44 45 import com.quadcap.util.Debug; 46 47 52 public class ExternProxyString implements ExternalizeProxy { 53 54 public Object readObject(ObjectInput in) throws IOException { 56 int cnt = in.readInt(); 57 if (cnt == -1) return null; 58 char[] buf = new char[cnt]; 59 for (int i = 0; i < cnt; i++) { 60 buf[i] = in.readChar(); 61 } 62 return new String (buf); 63 } 64 65 public void writeObject(ObjectOutput out, Object object) 66 throws IOException 67 { 68 if (object == null) { 69 out.writeInt(-1); 70 } else { 71 String s = (String )object; 72 int cnt = s.length(); 73 out.writeInt(cnt); 74 for (int i = 0; i < cnt; i++) { 75 out.writeChar(s.charAt(i)); 76 } 77 } 78 } 79 } 116 | Popular Tags |