Exemplo n.º 1
0
  /**
   * Method for parse DTNTime , return null if it can't pass
   *
   * @param bp Buffer pupulated with data
   */
  public static DTNTime decodeSDNV_and_Create_DTNTime(IByteBuffer bp) {
    DTNTime ret = new DTNTime();
    int sdnv_len = SDNV.len(bp);

    if (sdnv_len == -1) return null;
    else {
      decodeSDNV(ret, bp);
      return ret;
    }
  }
Exemplo n.º 2
0
  /**
   * Get the length of bytes can be decoded from the buffer
   *
   * @param n Length of buffer
   * @param bp Buffer to read bytes
   * @return Number of bytes can be decoded
   */
  public static int SDNVs_decoding_len(int n, IByteBuffer bp) {
    int old_position = bp.position();

    try {
      int sumSDNVs_len = 0;
      for (int i = 1; i <= n; i++) {
        int current_SDNV_len = SDNV.len(bp);
        if (current_SDNV_len == -1) return -1;

        bp.position(bp.position() + current_SDNV_len);
        sumSDNVs_len += current_SDNV_len;
      }
      return sumSDNVs_len;
    } finally {
      bp.position(old_position);
    }
  }