transcendental-lisp/src/environment/RuntimeEnvironment.java

66 lines
1.5 KiB
Java
Raw Normal View History

package environment;
import java.io.*;
public class RuntimeEnvironment {
private static RuntimeEnvironment uniqueInstance = new RuntimeEnvironment();
public static RuntimeEnvironment getInstance() {
2017-01-17 15:54:09 -05:00
return uniqueInstance;
}
private InputStream input;
private PrintStream output;
private PrintStream errorOutput;
private Runnable terminationFunction;
private Runnable errorTerminationFunction;
private RuntimeEnvironment() {}
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 setTerminationFunction(Runnable terminationFunction) {
this.terminationFunction = terminationFunction;
}
public void setErrorTerminationFunction(Runnable errorTerminationFunction) {
this.errorTerminationFunction = errorTerminationFunction;
}
public InputStream getInput() {
return input;
}
public String getInputName() {
return input.toString();
}
public PrintStream getOutput() {
return output;
}
public PrintStream getErrorOutput() {
return errorOutput;
}
public void terminateSuccessfully() {
terminationFunction.run();
}
public void terminateExceptionally() {
errorTerminationFunction.run();
}
}