Exemplo n.º 1
0
 /**
  * parse the data if the client status is successed
  *
  * @param data of type byte[] ,data from server-side need to parse
  */
 private void parseData(final byte data[]) {
   int len = data.length;
   int pos = 0;
   fieldOriData = new ArrayList<List<byte[]>>();
   // read field number
   fieldNumber = (int) ByteOrderUtil.getUnsignInt(data, pos);
   pos += 4;
   fieldTypes = new ArrayList<TDHSResponseEnum.IFieldType>(fieldNumber);
   for (int i = 0; i < fieldNumber; i++) {
     fieldTypes.add(TDHSResponseEnum.FieldType.valueOf(data[pos] & 0xFF));
     pos++;
   }
   while (pos < len) {
     List<byte[]> record = new ArrayList<byte[]>(fieldNumber);
     for (int i = 0; i < fieldNumber; i++) {
       int fieldLength = (int) ByteOrderUtil.getUnsignInt(data, pos);
       pos += 4;
       if (fieldLength > 0) {
         byte f[] = new byte[fieldLength];
         System.arraycopy(data, pos, f, 0, fieldLength);
         record.add(f);
         pos += fieldLength;
       } else {
         record.add(new byte[0]);
       }
     }
     fieldOriData.add(record);
   }
 }
Exemplo n.º 2
0
 /**
  * parse the data if the client status is not successed
  *
  * @param data of type byte[] ,data from server-side need to parse
  */
 private void parseFailed(final byte data[]) {
   int code = (int) ByteOrderUtil.getUnsignInt(data, 0);
   if (status == TDHSResponseEnum.ClientStatus.DB_ERROR) {
     dbErrorCode = code;
   } else {
     errorCode = TDHSResponseEnum.ErrorCode.valueOf(code);
   }
 }