public boolean encode(Routable obj, DocumentSerializer out) { if (!(obj instanceof DocumentReply)) { throw new AssertionError( "Document reply factory (" + getClass().getName() + ") registered for incompatible " + "routable type " + obj.getType() + "(" + obj.getClass().getName() + ")."); } DocumentReply reply = (DocumentReply)obj; out.putByte(null, (byte)(reply.getPriority().getValue())); return doEncode(reply, out); }
private byte[] encode(Utf8String protocolName, Routable toEncode) { if (toEncode.getType() == 0) { return new byte[0]; } return owner.getProtocol(protocolName).encode(Vtag.currentVersion, toEncode); }
@Override public byte[] encode(Version version, Routable routable) { if (routable.getType() == MESSAGE) { return Utf8.toBytes("M" + ((SimpleMessage)routable).getValue()); } else if (routable.getType() == REPLY) { return Utf8.toBytes("R" + ((SimpleReply)routable).getValue()); } else { return null; } }
public boolean encode(Routable obj, DocumentSerializer out) { if (!(obj instanceof DocumentMessage)) { throw new AssertionError( "Document message factory (" + getClass().getName() + ") registered for incompatible " + "routable type " + obj.getType() + "(" + obj.getClass().getName() + ")."); } DocumentMessage msg = (DocumentMessage)obj; out.putByte(null, (byte)(msg.getPriority().getValue())); out.putInt(null, msg.getLoadType().getId()); return doEncode(msg, out); }
int type = obj.getType(); RoutableFactory factory = getFactory(version, type); if (factory == null) {