001package org.xbib.elasticsearch.action.plugin.jdbc.run;
002
003import org.elasticsearch.action.support.nodes.NodesOperationResponse;
004import org.elasticsearch.common.io.stream.StreamInput;
005import org.elasticsearch.common.io.stream.StreamOutput;
006import org.elasticsearch.common.xcontent.ToXContent;
007import org.elasticsearch.common.xcontent.XContentBuilder;
008
009import java.io.IOException;
010
011public class RunRiverResponse extends NodesOperationResponse implements ToXContent {
012
013    private boolean[] executed;
014
015    public RunRiverResponse() {
016    }
017
018    public RunRiverResponse setExecuted(boolean[] b) {
019        this.executed = b;
020        return this;
021    }
022
023    public boolean[] isExecuted() {
024        return executed;
025    }
026
027    @Override
028    public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
029        builder.field("executed", executed);
030        return builder;
031    }
032
033    @Override
034    public void readFrom(StreamInput in) throws IOException {
035        super.readFrom(in);
036        int len = in.readInt();
037        executed = new boolean[len];
038        for (int i = 0; i < len; i++) {
039            executed[i] = in.readBoolean();
040        }
041    }
042
043    @Override
044    public void writeTo(StreamOutput out) throws IOException {
045        super.writeTo(out);
046        out.writeInt(executed.length);
047        for (boolean b : executed) {
048            out.writeBoolean(b);
049        }
050    }
051
052}