// Path: java/src/main/java/com/circonus/FqDataProtocolError.java
// public class FqDataProtocolError extends Exception {
//   public FqDataProtocolError(String a) {
//     super(a);
//   }
// }


import java.io.IOException;
import java.net.InetAddress;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
import com.circonus.FqDataProtocolError;
  public void setSender(byte[] _r) { sender = _r; sender_len = _r.length; }
  public void setExchange(byte[] _r) { exchange = _r; exchange_len = _r.length; }
  public void setMsgId() {
    UUID uuid = UUID.randomUUID();
    ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
    bb.putLong(uuid.getMostSignificantBits());
    bb.putLong(uuid.getLeastSignificantBits());
    sender_msgid = new MsgId(bb.array());
  }
  public void setPayload(byte[] _r) { payload = _r; payload_len = _r.length; }

  public String getRoute() { return new String(route, StandardCharsets.UTF_8); }
  public String getExchange() { return new String(exchange, StandardCharsets.UTF_8); }
  public String getSender() { return new String(sender, StandardCharsets.UTF_8); }
  public MsgId getMsgId() { return sender_msgid; }
  public byte[] getPayload() { return payload; }
  public InetAddress[] getPath() { return hops; }

  public boolean isComplete(boolean peermode) {
    if(peermode) {
      if(nhops < 0 || hops == null || sender_len < 0 || sender == null)
        return false;
    }
    if(route_len <= 0 || route == null ||
      exchange_len <= 0 || exchange == null ||
      payload_len < 0 || payload == null || sender_msgid == null)
      return false;
    return true;
  }
  public boolean isComplete() { return _complete; }
// Path: java/src/main/java/com/circonus/FqDataProtocolError.java
// public class FqDataProtocolError extends Exception {
//   public FqDataProtocolError(String a) {
//     super(a);
//   }
// }


// Path: java/src/main/java/com/circonus/FqMessage.java
import java.io.IOException;
import java.net.InetAddress;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
import com.circonus.FqDataProtocolError;

  public void setSender(byte[] _r) { sender = _r; sender_len = _r.length; }
  public void setExchange(byte[] _r) { exchange = _r; exchange_len = _r.length; }
  public void setMsgId() {
    UUID uuid = UUID.randomUUID();
    ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
    bb.putLong(uuid.getMostSignificantBits());
    bb.putLong(uuid.getLeastSignificantBits());
    sender_msgid = new MsgId(bb.array());
  }
  public void setPayload(byte[] _r) { payload = _r; payload_len = _r.length; }

  public String getRoute() { return new String(route, StandardCharsets.UTF_8); }
  public String getExchange() { return new String(exchange, StandardCharsets.UTF_8); }
  public String getSender() { return new String(sender, StandardCharsets.UTF_8); }
  public MsgId getMsgId() { return sender_msgid; }
  public byte[] getPayload() { return payload; }
  public InetAddress[] getPath() { return hops; }

  public boolean isComplete(boolean peermode) {
    if(peermode) {
      if(nhops < 0 || hops == null || sender_len < 0 || sender == null)
        return false;
    }
    if(route_len <= 0 || route == null ||
      exchange_len <= 0 || exchange == null ||
      payload_len < 0 || payload == null || sender_msgid == null)
      return false;
    return true;
  }
  public boolean isComplete() { return _complete; }
  public boolean read(FqClient c) throws IOException, FqDataProtocolError {