Package com.impossibl.postgres.api.data

Examples of com.impossibl.postgres.api.data.Record


        test(expectedAttrs[c], actualAttrs[c]);
      }
    }
    else if (expected instanceof Record) {

      Record expectedStruct = (Record) expected;
      Object[] expectedAttrs = expectedStruct.getValues();

      Record actualStruct = (Record) actual;
      Object[] actualAttrs = actualStruct.getValues();

      assertEquals("Record Length", expectedAttrs.length, actualAttrs.length);
      for (int c = 0; c < expectedAttrs.length; ++c) {
        test(expectedAttrs[c], actualAttrs[c]);
      }
View Full Code Here


        Class<?> attrTargetType = mapSetType(format, attrType);

        attributeVals[c] = coerce(format, attributeVals[c], attrType, attrTargetType, typeMap, zone, connection);
      }

      return new Record(compType, attributeVals);
    }

    throw createCoercionException(val.getClass(), Struct.class);
  }
View Full Code Here

        Struct struct = (Struct) val;
        attributeVals = struct.getAttributes();
      }
      else if (val instanceof Record) {

        Record record = (Record) val;
        attributeVals = record.getValues();
      }
      else {

        throw createCoercionException(val.getClass(), targetType);
      }
View Full Code Here

    @Override
    public Object decode(Type type, Short typeLength, Integer typeModifier, ByteBuf buffer, Context context) throws IOException {

      CompositeType compType = (CompositeType) type;

      Record record = null;

      int length = buffer.readInt();

      if (length != -1) {

        long readStart = buffer.readerIndex();

        int itemCount = buffer.readInt();

        Object[] attributeVals = new Object[itemCount];

        for (int c = 0; c < itemCount; ++c) {

          Attribute attribute = compType.getAttribute(c + 1);

          Type attributeType = context.getRegistry().loadType(buffer.readInt());

          if (attributeType.getId() != attribute.type.getId()) {

            context.refreshType(attributeType.getId());
          }

          Object attributeVal = attributeType.getBinaryCodec().decoder.decode(attributeType, null, null, buffer, context);

          attributeVals[c] = attributeVal;
        }

        if (length != buffer.readerIndex() - readStart) {
          throw new IllegalStateException();
        }

        record = new Record(compType, attributeVals);
      }

      return record;
    }
View Full Code Here

      if (val != null) {

        int writeStart = buffer.writerIndex();

        Record record = (Record) val;

        Object[] attributeVals = record.getValues();

        CompositeType compType = (CompositeType) type;

        Collection<Attribute> attributes = compType.getAttributes();
View Full Code Here

      int length = 4;

      if (val != null) {

        Record record = (Record) val;

        Object[] attributeVals = record.getValues();

        CompositeType compType = (CompositeType) type;

        Collection<Attribute> attributes = compType.getAttributes();
View Full Code Here

      if (length != 0) {

        instance = readComposite(buffer, type.getDelimeter(), (CompositeType) type, context);
      }

      return new Record((CompositeType)type, instance);
    }
View Full Code Here

TOP

Related Classes of com.impossibl.postgres.api.data.Record

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.