Java Class Hello2

import jekpro.tools.api.Interpreter;

/**
* <p>Java code for the hello argument example.</p>
* <p>With thorough exception handling.</p>
*
* @author Copyright 2011-2013, XLOG Technologies GmbH, Switzerland
* @version Jekejeke Prolog 0.9.0 (a fast and small prolog interpreter)
*/
public class Hello {

/**
* <p>Hello the argument.</p>
*
* @param inter The interpreter.
* @param arg The argument.
* @throws InterpreterMessage Problems with writing.
*/
public static void hello(Interpreter inter,
String arg) throws InterpreterMessage {
Object obj = ((TermRef)inter.getProperty(
ToolkitLibrary.PROP_SYS_CUR_OUTPUT)).getValue();
if (!(obj instanceof Writer))
throw new InterpreterMessage(
InterpreterMessage.permissionError("output",
"binary_stream", new TermAtom("user_output")));
try {
Writer wr = (Writer)obj;
wr.write("Hello ");
wr.write(arg);
wr.write('\n');
wr.flush();
} catch (IOException x) {
throw InterpreterMessage.mapIOException(x, inter);
}
}

}

Comments