1 package cz.cuni.amis.pogamut.ut2004.tournament.botexecution;
2
3 import java.io.File;
4
5 import cz.cuni.amis.pogamut.ut2004.tournament.match.UT2004BotConfig;
6 import cz.cuni.amis.utils.NullCheck;
7 import cz.cuni.amis.utils.token.IToken;
8 import cz.cuni.amis.utils.token.Tokens;
9
10 public class UT2004BotExecutionConfig {
11
12
13
14
15
16
17 private IToken botId;
18
19
20
21
22 private String pathToBotJar = null;
23
24
25
26
27 private boolean redirectStdErr = true;
28
29
30
31
32 private boolean redirectStdOut = true;
33
34
35
36
37 private File fileToJar;
38
39
40
41
42
43
44
45
46 public IToken getBotId() {
47 return botId;
48 }
49
50
51
52
53 public UT2004BotExecutionConfig() {
54 }
55
56
57
58
59
60 public UT2004BotExecutionConfig(UT2004BotConfig value) {
61 this.botId = value.getBotId();
62 this.setPathToBotJar(value.getPathToBotJar());
63 this.redirectStdErr = value.isRedirectStdErr();
64 this.redirectStdOut = value.isRedirectStdOut();
65 }
66
67
68
69
70
71
72
73
74 public UT2004BotExecutionConfig setBotId(String botId) {
75 NullCheck.check(botId, "botId");
76 this.botId = Tokens.get(botId);
77 return this;
78 }
79
80
81
82
83
84
85
86
87 public UT2004BotExecutionConfig setBotId(IToken botId) {
88 NullCheck.check(botId, "botId");
89 this.botId = botId;
90 return this;
91 }
92
93
94
95
96
97 public String getPathToBotJar() {
98 return pathToBotJar;
99 }
100
101
102
103
104
105 public UT2004BotExecutionConfig setPathToBotJar(String pathToBotJar) {
106 if (pathToBotJar != null) {
107 this.fileToJar = new File(pathToBotJar);
108 } else {
109 this.fileToJar = null;
110 }
111 this.pathToBotJar = pathToBotJar;
112 return this;
113 }
114
115
116
117
118
119 public boolean isBotJarExist() {
120 if (this.pathToBotJar == null) return false;
121 File file = getJarFile();
122 return file.exists() && file.isFile();
123 }
124
125
126
127
128
129 public File getJarFile() {
130 return fileToJar;
131 }
132
133
134
135
136
137 public boolean isRedirectStdErr() {
138 return redirectStdErr;
139 }
140
141
142
143
144
145 public UT2004BotExecutionConfig setRedirectStdErr(boolean redirectStdErr) {
146 this.redirectStdErr = redirectStdErr;
147 return this;
148 }
149
150
151
152
153
154 public boolean isRedirectStdOut() {
155 return redirectStdOut;
156 }
157
158
159
160
161
162 public UT2004BotExecutionConfig setRedirectStdOut(boolean redirectStdOut) {
163 this.redirectStdOut = redirectStdOut;
164 return this;
165 }
166
167 @Override
168 public String toString() {
169 return "UT2004BotExecutionConfig[botId=" + botId.getToken() + ", jar=" + pathToBotJar + "]";
170 }
171
172 }