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

com.github.housepower.jdbc.protocol.QueryResponse Maven / Gradle / Ivy

There is a newer version: 2.7.1
Show newest version
package com.github.housepower.jdbc.protocol;

import com.github.housepower.jdbc.data.Block;

import java.util.ArrayList;
import java.util.List;

public class QueryResponse {
    
    private final Block header;
    private final List data;
    // Progress
    // Totals
    // Extremes
    // ProfileInfo
    // EndOfStream

    public QueryResponse(List responses) {
        List dataResponses = new ArrayList(responses.size());
        List totalsResponses = new ArrayList(responses.size());
        List progressResponses = new ArrayList(responses.size());
        List extremesResponses = new ArrayList(responses.size());
        List profileInfoResponses = new ArrayList(responses.size());

        for (RequestOrResponse response : responses) {
            if (response instanceof DataResponse) {
                dataResponses.add((DataResponse) response);
            } else if (response instanceof TotalsResponse) {
                totalsResponses.add((TotalsResponse) response);
            } else if (response instanceof ProgressResponse) {
                progressResponses.add((ProgressResponse) response);
            } else if (response instanceof ExtremesResponse) {
                extremesResponses.add((ExtremesResponse) response);
            } else if (response instanceof ProfileInfoResponse) {
                profileInfoResponses.add((ProfileInfoResponse) response);
            }
        }

        data = dataResponses;
        header = dataResponses.isEmpty() ? new Block() : dataResponses.remove(0).block();
    }

    public Block header() {
        return header;
    }

    public List data() {
        return data;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy