Package com.impossibl.postgres.types

Examples of com.impossibl.postgres.types.Type


    @Override
    public void encode(Type type, StringBuilder buffer, Object value, Context context) throws IOException {

      DomainType domainType = (DomainType) type;
      Type baseType = domainType.getBase();

      baseType.getTextCodec().encoder.encode(baseType, buffer, value, context);
    }
View Full Code Here


  @Override
  public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
    checkClosed();

    Type type = getRegistry().loadType(typeName + "[]");
    if (type == null) {
      throw new SQLException("Array type not found");
    }

    return new PGArray(this, (ArrayType)type, elements);
View Full Code Here

  @Override
  public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
    checkClosed();

    Type type = getRegistry().loadType(typeName);
    if (!(type instanceof CompositeType)) {
      throw new SQLException("Invalid type for struct");
    }

    return new PGStruct(this, (CompositeType)type, attributes);
View Full Code Here

        //Header
        //

        int dimensionCount = buffer.readInt();
        /* boolean hasNulls = */ buffer.readInt() /* == 1 ? true : false */;
        Type elementType = context.getRegistry().loadType(buffer.readInt());

        //Each Dimension
        int[] dimensions = new int[dimensionCount];
        int[] lowerBounds = new int[dimensionCount];
        for (int d = 0; d < dimensionCount; ++d) {

          //Dimension
          dimensions[d] = buffer.readInt();

          //Lower bounds
          lowerBounds[d] = buffer.readInt();
        }

        if (atype.getElementType().getId() != elementType.getId()) {
          context.refreshType(atype.getId());
        }

        //
        //Array & Elements
View Full Code Here

    }
    else {
      buffer.writeShort(paramTypes.size());
      for (int c = 0; c < paramTypes.size(); ++c) {

        Type paramType = paramTypes.get(c);
        Object paramValue = paramValues.get(c);

        Type.Codec codec = paramType.getCodec(paramType.getParameterFormat());
        codec.encoder.encode(paramType, buffer, paramValue, context);

      }
    }
  }
View Full Code Here

    }
    else {
      length += 2;
      for (int c = 0; c < paramTypes.size(); ++c) {

        Type paramType = paramTypes.get(c);
        Object paramValue = paramValues.get(c);

        Type.Codec codec = paramType.getCodec(paramType.getParameterFormat());
        length += codec.encoder.length(paramType, paramValue, context);

      }
    }
View Full Code Here

      if (val != null) {

        int writeStart = buffer.writerIndex();

        ArrayType atype = ((ArrayType)type);
        Type elementType = atype.getElementType();

        //
        //Header
        //

        int dimensionCount = getDimensions(val.getClass(), atype.unwrapAll());
        //Dimension count
        buffer.writeInt(dimensionCount);
        //Has nulls
        buffer.writeInt(hasNulls(val) ? 1 : 0);
        //Element type
        buffer.writeInt(elementType.getId());

        //each dimension
        Object dim = val;
        for (int d = 0; d < dimensionCount; ++d) {
View Full Code Here

      int length = 4;

      if (val != null) {

        ArrayType arrayType = (ArrayType) type;
        Type elementType = arrayType.unwrapAll();

        int dimensionCount = getDimensions(val.getClass(), arrayType.unwrapAll());

        length += 12 + (dimensionCount * 8);

 
View Full Code Here

    @Override
    public void encode(Type type, StringBuilder buffer, Object val, Context context) throws IOException {

      ArrayType arrayType = (ArrayType) type;

      Type elementType = arrayType.getElementType();

      writeArray(buffer, elementType.getDelimeter(), elementType, val, context);

    }
View Full Code Here

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

        ResultField field = resultBatch.fields.get(c);

        Type fieldType = field.typeRef.get();

        Type.Codec.Decoder decoder = fieldType.getCodec(field.format).decoder;

        Object fieldVal = decoder.decode(fieldType, field.typeLength, field.typeModifier, buffer, context);

        rowInstance[c] = fieldVal;
      }
View Full Code Here

TOP

Related Classes of com.impossibl.postgres.types.Type

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.