Package org.adbcj.postgresql.codec

Examples of org.adbcj.postgresql.codec.PgField


  @Test
  public void rowDescription() throws Exception {
    RowDescriptionMessage message = decode(ROW_DESCRIPTION);
    Assert.assertEquals(message.getType(), BackendMessageType.ROW_DESCRIPTION);
    Assert.assertEquals(message.getFields().length, 1);
    PgField field = message.getFields()[0];
    Assert.assertEquals(field.getColumnLabel(), "id");
    Assert.assertEquals(field.getColumnType(), Type.INTEGER);
  }
View Full Code Here


    int fieldCount = input.readUnsignedShort();
    Value[] values = new Value[fieldCount];
    for (int i = 0; i < fieldCount; i++) {
      int valueLength = input.readInt();
      PgField field = fields[i];
      Value value;
      if (valueLength < 0) {
        value = new DefaultValue(field, null);
      } else {
        String strVal;
        switch (field.getColumnType()) {
        case INTEGER:
          switch (field.getFormatCode()) {
          case BINARY:
            value = new DefaultValue(field, input.readInt());
            break;
          case TEXT:
            strVal = input.readString(valueLength, charset);
            value = new DefaultValue(field, Integer.valueOf(strVal));
            break;
          default:
            throw new IllegalStateException("Unable to decode format of " + field.getFormatCode());
          }
          break;
        case BIGINT:
          switch (field.getFormatCode()) {
          case BINARY:
            value = new DefaultValue(field, (long)input.readInt() << 32 | input.readInt());
            break;
          case TEXT:
            strVal = input.readString(valueLength, charset);
            value = new DefaultValue(field, Long.valueOf(strVal));
            break;
          default:
            throw new IllegalStateException("Unable to decode format of " + field.getFormatCode());
          }
          break;
        case VARCHAR:
          strVal = input.readString(valueLength, charset);
          value = new DefaultValue(field, strVal);
          break;
        default:
          // Advance buffer
          input.skip(valueLength);
          // TODO Handle remaining ADBCJ types
          throw new IllegalStateException("Unable to decode column of type " + field.getColumnType());
        }
      }
      values[i] = value;
    }
    return new DataRowMessage(values);
View Full Code Here

      default:
        // TODO Convert more typeOids to ADBCJ types
        throw new IllegalStateException("Unable to handle field type with oid " + typeOid);
      }

      fields[i] = new PgField(
          i,
          connectionState.getDatabaseName(),
          type,
          name,
          tableOid,
View Full Code Here

TOP

Related Classes of org.adbcj.postgresql.codec.PgField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.