package net.northking.cctp.upperComputer.driver.agent.command;

import net.northking.cctp.upperComputer.driver.agent.command.protocol.AbstractProtocolCommand;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class TextInputCommand extends AbstractProtocolCommand<Object> {

    private boolean clear = false;

    private String text = "";

    public TextInputCommand() {
    }

    public TextInputCommand(String text) {
        this.text = text;
        if (text == null) {
            text = "";
        }
    }

    public TextInputCommand(boolean clear, String text) {
        this.clear = clear;
        this.text = text;
        if (text == null) {
            text = "";
        }
    }

    public void setClear(boolean clear) {
        this.clear = clear;
    }

    public void setText(String text) {
        if (text != null) {
            this.text = text;
        }
    }

    public boolean isClear() {
        return clear;
    }

    public String getText() {
        return text;
    }

    @Override
    public int getCommandId() {
        return 30;
    }

    @Override
    public void doSend(DataOutput output) throws IOException {
        output.writeBoolean(clear);
        sendText(output, text);
    }

    @Override
    public Object buildReceive(DataInput input) throws IOException {
        return null;
    }
}
