Beispiel #1
0
  /**
   * Decode the data in the buffer and set the all the values in the DTNTime
   *
   * @param dt Empty DTNTime to store decoded DTNTime
   * @param buf Serializable Buffer to read and recode DTNTime
   */
  public static void decodeSDNV(DTNTime dt, IByteBuffer buf) {
    long[] decoded_seconds = new long[1];
    long[] decoded_nanoseconds = new long[1];
    SDNV.decode(buf, decoded_seconds);
    dt.set_seconds(decoded_seconds[0]);

    SDNV.decode(buf, decoded_nanoseconds);
    dt.set_nanoseconds(decoded_nanoseconds[0]);
  }
  /**
   * decode the value from the buffer and return
   *
   * @param buf Buffer to read encoded value form
   * @param val Get the empty array and set the decoded value on the first index of array
   * @return Number of bytes decoded
   */
  public int read_sdnv(IByteBuffer buf, int[] val) throws BlockProcessorTooShortException {

    int sdnv_len = SDNV.decode(buf, val);
    if (sdnv_len < 1) {
      throw new BlockProcessorTooShortException();
    }
    assert (sdnv_len < 0) : TAG + "read sdnv: incorrect length";

    return sdnv_len;
  }