public String readObject(ByteBuffer data, Class c) throws IOException { return readString(data); }
public void writeObject(ByteBuffer buffer, Object object) throws IOException { String string = (String)object; writeString(string, buffer); } }
registerClass(Float.class, new FloatSerializer()); registerClass(Double.class, new DoubleSerializer()); registerClass(String.class, new StringSerializer());
public void writeObject( ByteBuffer buffer, Object object ) throws IOException { if( object == null ) { buffer.putShort((short)-1); return; } Field field = (Field)object; writeClass( buffer, field.getDeclaringClass() ); delegate.writeObject( buffer, field.getName() ); } }
@Override public <T> T readObject( ByteBuffer data, Class<T> c ) throws IOException { // Use serializer's support for class reading/writing SerializerRegistration reg = readClass(data); if( reg == null || reg.getType() == Void.class ) { return null; } Class type = reg.getType(); String name = delegate.readObject( data, String.class ); try { Field result = type.getDeclaredField(name); return c.cast(result); } catch( NoSuchFieldException e ) { throw new IOException( "Error resolving field:" + name + " on:" + type, e ); } }
registerClass(Float.class, new FloatSerializer()); registerClass(Double.class, new DoubleSerializer()); registerClass(String.class, new StringSerializer());
public DisconnectMessage readObject( ByteBuffer data, Class c ) throws IOException { // Read the null/non-null marker if (data.get() == 0x0) return null; DisconnectMessage msg = new DisconnectMessage(); msg.reason = StringSerializer.readString(data); msg.type = StringSerializer.readString(data); return msg; }
public void writeObject(ByteBuffer buffer, Object object) throws IOException { // Add the null/non-null marker buffer.put( (byte)(object != null ? 0x1 : 0x0) ); if (object == null) { // Nothing left to do return; } DisconnectMessage msg = (DisconnectMessage)object; StringSerializer.writeString( msg.reason, buffer ); StringSerializer.writeString( msg.type, buffer ); } }
public ClientRegistrationMessage readObject( ByteBuffer data, Class c ) throws IOException { // Read the null/non-null marker if (data.get() == 0x0) return null; ClientRegistrationMessage msg = new ClientRegistrationMessage(); msg.gameName = StringSerializer.readString(data); msg.id = data.getLong(); msg.version = data.getInt(); return msg; }
public void writeObject(ByteBuffer buffer, Object object) throws IOException { // Add the null/non-null marker buffer.put( (byte)(object != null ? 0x1 : 0x0) ); if (object == null) { // Nothing left to do return; } ClientRegistrationMessage msg = (ClientRegistrationMessage)object; StringSerializer.writeString( msg.gameName, buffer ); buffer.putLong(msg.id); buffer.putInt(msg.version); } }
public String readObject(ByteBuffer data, Class c) throws IOException { return readString(data); }
public void writeObject(ByteBuffer buffer, Object object) throws IOException { String string = (String)object; writeString(string, buffer); } }
public DisconnectMessage readObject( ByteBuffer data, Class c ) throws IOException { // Read the null/non-null marker if (data.get() == 0x0) return null; DisconnectMessage msg = new DisconnectMessage(); msg.reason = StringSerializer.readString(data); msg.type = StringSerializer.readString(data); return msg; }
public void writeObject(ByteBuffer buffer, Object object) throws IOException { // Add the null/non-null marker buffer.put( (byte)(object != null ? 0x1 : 0x0) ); if (object == null) { // Nothing left to do return; } DisconnectMessage msg = (DisconnectMessage)object; StringSerializer.writeString( msg.reason, buffer ); StringSerializer.writeString( msg.type, buffer ); } }
public ClientRegistrationMessage readObject( ByteBuffer data, Class c ) throws IOException { // Read the null/non-null marker if (data.get() == 0x0) return null; ClientRegistrationMessage msg = new ClientRegistrationMessage(); msg.gameName = StringSerializer.readString(data); msg.id = data.getLong(); msg.version = data.getInt(); return msg; }
public void writeObject(ByteBuffer buffer, Object object) throws IOException { // Add the null/non-null marker buffer.put( (byte)(object != null ? 0x1 : 0x0) ); if (object == null) { // Nothing left to do return; } ClientRegistrationMessage msg = (ClientRegistrationMessage)object; StringSerializer.writeString( msg.gameName, buffer ); buffer.putLong(msg.id); buffer.putInt(msg.version); } }