package net.northking.cctp.upperComputer.driver.ios.packet;

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

public class TextCommandData implements ICommandData {

    private String text = "";

    public String getText() {
        return text;
    }

    public void setText(String text) {
        if (text == null) throw new IllegalArgumentException("此处text不能为null");
        this.text = text;
    }

    @Override
    public void buildFromInput(DataInput dataInput) throws IOException {
        text = CodecUtils.readText(dataInput);
    }

    @Override
    public void encodeToOutput(DataOutput dataOutput) throws IOException {
        CodecUtils.writeText(dataOutput, text);
    }

    @Override
    public String toString() {
        return "TextCommandData{" +
                "text='" + text + '\'' +
                '}';
    }
}
