aboutsummaryrefslogtreecommitdiff
path: root/src/cz/crcs/ectester/common/output/TestableWriter.java
blob: 987606455b350fb65e86bf824118209438891021 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package cz.crcs.ectester.common.output;

import cz.crcs.ectester.common.test.BaseTestable;
import cz.crcs.ectester.reader.output.ResponseWriter;
import cz.crcs.ectester.reader.response.Response;
import cz.crcs.ectester.reader.test.CommandTestable;
import cz.crcs.ectester.standalone.test.KeyAgreementTestable;
import cz.crcs.ectester.standalone.test.KeyGeneratorTestable;
import cz.crcs.ectester.standalone.test.SignatureTestable;

import java.io.OutputStream;
import java.io.PrintStream;

/**
 * @author Jan Jancar johny@neuromancer.sk
 */
public class TestableWriter {
    private PrintStream output;
    private ResponseWriter respWriter;

    public TestableWriter(PrintStream output) {
        this.output = output;
        this.respWriter = new ResponseWriter(output);
    }

    public TestableWriter(OutputStream output) {
        this(new PrintStream(output));
    }

    public String outputTestableSuffix(BaseTestable t) {
        if (t instanceof CommandTestable) {
            Response r = ((CommandTestable) t).getResponse();
            return respWriter.responseSuffix(r);
        } else if (t instanceof KeyAgreementTestable) {

        } else if (t instanceof KeyGeneratorTestable) {

        } else if (t instanceof SignatureTestable) {

        }
        return null;
    }

    public void writeTestableSuffix(BaseTestable t) {
        output.println(outputTestableSuffix(t));
    }

    public String outputTestable(BaseTestable t) {
        if (t instanceof CommandTestable) {
            CommandTestable testable = (CommandTestable) t;
            return respWriter.responseString(testable.getResponse());
        } else if (t instanceof KeyAgreementTestable) {

        } else if (t instanceof KeyGeneratorTestable) {

        } else if (t instanceof SignatureTestable) {

        }
        return null;
    }

    public void writeTestable(BaseTestable t) {
        output.println(outputTestable(t));
    }
}