All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.redkalex.source.pgsql.PgRespParamDescDecoder Maven / Gradle / Ivy

There is a newer version: 2.7.7
Show newest version
/*
 *
 */
package org.redkalex.source.pgsql;

import static org.redkalex.source.pgsql.PgClientCodec.*;

import java.nio.ByteBuffer;
import org.redkale.source.SourceException;
import org.redkale.util.ByteArray;

/** @author zhangjx */
public class PgRespParamDescDecoder extends PgRespDecoder {

    public static final PgRespParamDescDecoder instance = new PgRespParamDescDecoder();

    private PgRespParamDescDecoder() {}

    @Override
    public byte messageid() {
        return MESSAGE_TYPE_PARAMETER_DESCRIPTION; // 't'
    }

    @Override
    public PgColumnFormat[] read(
            PgClientConnection conn,
            ByteBuffer buffer,
            final int length,
            ByteArray array,
            PgClientRequest request,
            PgResultSet dataset) {
        PgColumnFormat[] formats = new PgColumnFormat[buffer.getShort() & 0xFFFF];
        for (int i = 0; i < formats.length; i++) {
            int oid = buffer.getInt();
            formats[i] = PgColumnFormat.valueOf(oid);
            if (formats[i].encoder() == null) {
                throw new SourceException("Unsupported data encode ColumnFormat: " + formats[i]);
            }
        }
        return formats;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy