protected static void writeAuthToken(DataOutput out, AuthToken tok) throws Exception { out.writeByte(tok == null? 0 : 1); if(tok == null) return; short id=ClassConfigurator.getMagicNumber(tok.getClass()); out.writeShort(id); if(id < 0) { String classname=tok.getClass().getName(); out.writeUTF(classname); } tok.writeTo(out); }
private static void writeOtherAddress(Address addr,DataOutput out) throws Exception { short magic_number=ClassConfigurator.getMagicNumber(addr.getClass()); // write the class info if(magic_number == -1) throw new RuntimeException("magic number " + magic_number + " not found"); out.writeShort(magic_number); addr.writeTo(out); }
protected static int sizeOf(AuthToken tok) { int retval=Global.BYTE_SIZE; // null token ? if(tok == null) return retval; retval+=Global.SHORT_SIZE; short id=ClassConfigurator.getMagicNumber(tok.getClass()); if(id < 0) { String classname=tok.getClass().getName(); retval+=classname.length() +2; } retval+=tok.size(); return retval; }
public static void writeGenericStreamable(Streamable obj, DataOutput out) throws Exception { short magic_number; String classname; if(obj == null) { out.write(0); return; } out.write(1); magic_number=ClassConfigurator.getMagicNumber(obj.getClass()); out.writeShort(magic_number); if(magic_number == -1) { classname=obj.getClass().getName(); out.writeUTF(classname); } obj.writeTo(out); // write the contents }
private static void writeOtherAddress(Address addr,DataOutput out) throws Exception { short magic_number=ClassConfigurator.getMagicNumber(addr.getClass()); // write the class info if(magic_number == -1) throw new RuntimeException("magic number " + magic_number + " not found"); out.writeShort(magic_number); addr.writeTo(out); }
protected static void writeAuthToken(DataOutput out, AuthToken tok) throws Exception { out.writeByte(tok == null? 0 : 1); if(tok == null) return; short id=ClassConfigurator.getMagicNumber(tok.getClass()); out.writeShort(id); if(id < 0) { String classname=tok.getClass().getName(); out.writeUTF(classname); } tok.writeTo(out); }
protected static int sizeOf(AuthToken tok) { int retval=Global.BYTE_SIZE; // null token ? if(tok == null) return retval; retval+=Global.SHORT_SIZE; short id=ClassConfigurator.getMagicNumber(tok.getClass()); if(id < 0) { String classname=tok.getClass().getName(); retval+=classname.length() +2; } retval+=tok.size(); return retval; }
public static void writeGenericStreamable(Streamable obj, DataOutput out) throws Exception { short magic_number; String classname; if(obj == null) { out.write(0); return; } out.write(1); magic_number=ClassConfigurator.getMagicNumber(obj.getClass()); out.writeShort(magic_number); if(magic_number == -1) { classname=obj.getClass().getName(); out.writeUTF(classname); } obj.writeTo(out); // write the contents }
private static void writeOtherAddress(Address addr, DataOutputStream out) throws IOException { ClassConfigurator conf=null; try { conf=ClassConfigurator.getInstance(false); } catch(ChannelException e) { IOException new_ex=new IOException(); new_ex.initCause(e); throw new_ex; } short magic_number=conf != null? conf.getMagicNumber(addr.getClass()) : -1; // write the class info if(magic_number == -1) { out.write(0); out.writeUTF(addr.getClass().getName()); } else { out.write(1); out.writeShort(magic_number); } // write the data itself addr.writeTo(out); }
public static void writeGenericStreamable(Streamable obj, DataOutputStream out) throws IOException { short magic_number; String classname; if(obj == null) { out.write(0); return; } try { out.write(1); magic_number=ClassConfigurator.getInstance(false).getMagicNumber(obj.getClass()); // write the magic number or the class name if(magic_number == -1) { out.writeBoolean(false); classname=obj.getClass().getName(); out.writeUTF(classname); } else { out.writeBoolean(true); out.writeShort(magic_number); } // write the contents obj.writeTo(out); } catch(ChannelException e) { throw new IOException("failed writing object of type " + obj.getClass() + " to stream: " + e.toString()); } }
short magic=mConfigurator.getMagicNumber(inst.getClass());
int size=value.size(); try { magic_number=ClassConfigurator.getInstance(false).getMagicNumber(value.getClass());