2017-01-17 13:54:21 -05:00
|
|
|
package environment;
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
|
|
|
|
public class Environment {
|
|
|
|
|
2017-01-17 15:54:09 -05:00
|
|
|
private static Environment uniqueInstance = new Environment();
|
2017-01-17 13:54:21 -05:00
|
|
|
|
|
|
|
public static Environment getInstance() {
|
2017-01-17 15:54:09 -05:00
|
|
|
return uniqueInstance;
|
2017-01-17 13:54:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
private InputStream input;
|
|
|
|
private PrintStream output;
|
|
|
|
private PrintStream errorOutput;
|
|
|
|
private Runnable terminate;
|
|
|
|
|
|
|
|
private Environment() {}
|
|
|
|
|
|
|
|
public void setInput(InputStream input) {
|
|
|
|
this.input = input;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setOutput(PrintStream output) {
|
|
|
|
this.output = output;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setErrorOutput(PrintStream errorOutput) {
|
|
|
|
this.errorOutput = errorOutput;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setTerminate(Runnable terminate) {
|
|
|
|
this.terminate = terminate;
|
|
|
|
}
|
|
|
|
|
|
|
|
public InputStream getInput() {
|
|
|
|
return input;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getInputName() {
|
|
|
|
return input.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
public PrintStream getOutput() {
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
public PrintStream getErrorOutput() {
|
|
|
|
return errorOutput;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void terminate() {
|
|
|
|
terminate.run();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|