001 package railo.commons.lang; 002 003 import java.io.IOException; 004 import java.io.ObjectInput; 005 import java.io.ObjectOutput; 006 007 public class ExternalizableUtil { 008 009 public static String readString(ObjectInput in) throws ClassNotFoundException, IOException { 010 return (String) in.readObject(); 011 } 012 013 public static void writeString(ObjectOutput out, String str) throws IOException { 014 if(str==null) out.writeObject("") ; 015 else out.writeObject(str); 016 } 017 018 public static Boolean readBoolean(ObjectInput in) throws IOException { 019 int b=in.readInt(); 020 if(b==-1) return null; 021 return b==1?Boolean.TRUE:Boolean.FALSE; 022 } 023 024 public static void writeBoolean(ObjectOutput out,Boolean b) throws IOException { 025 if(b==null) out.writeInt(-1) ; 026 else out.writeInt(b.booleanValue()?1:0); 027 } 028 }