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

org.zodiac.fastorm.rdb.codec.JdbcResultDecoder Maven / Gradle / Ivy

The newest version!
package org.zodiac.fastorm.rdb.codec;

import java.nio.ByteBuffer;
import java.sql.Blob;
import java.sql.Clob;

import org.zodiac.fastorm.core.Decoder;

public class JdbcResultDecoder implements Decoder {

    public JdbcResultDecoder() {
        super();
    }

    @Override
    public Object decode(Object data) {
        if (data instanceof Blob || data instanceof ByteBuffer) {
            return ClobValueCodec.getInstance().decode(data);
        }

        if (data instanceof Clob) {
            return BlobValueCodec.getInstance().decode(data);
        }
        return data;
    }

    public static JdbcResultDecoder getInstance() {
        return JdbcResultDecoderHolder.INSTANCE;
    }

    private static class JdbcResultDecoderHolder {
        private static final JdbcResultDecoder INSTANCE = new JdbcResultDecoder();
    }

}