/pluggablejs/trunk/src/net/outlyer/plugins/utils/Input.java |
---|
0,0 → 1,34 |
package net.outlyer.plugins.utils; |
import java.io.IOException; |
import java.io.InputStream; |
/** |
* |
*/ |
public class Input { |
private final InputStream in; |
{ |
in = System.in; |
} |
public String readline() { |
final StringBuilder sb = new StringBuilder(); |
int c; |
try { |
do { |
c = in.read(); |
sb.append((char) c); |
} while (0 != c && '\n' != c); |
} |
catch (final IOException e) { |
return null; |
} |
return sb.toString(); |
} |
} |
/pluggablejs/trunk/src/net/outlyer/plugins/utils/Output.java |
---|
0,0 → 1,32 |
package net.outlyer.plugins.utils; |
import java.io.PrintStream; |
/** |
* Provides a simplified wrapper for output |
*/ |
public class Output { |
private final PrintStream ps; |
public Output(final PrintStream ps) { |
this.ps = ps; |
} |
public void println(final String s) { |
ps.println(s); |
} |
/** |
* Note that varargs can't be used transparently from JS |
* @param sfmt |
* @param args |
*/ |
public void printf(final String sfmt, final Object [] args) { |
ps.printf(sfmt, args); |
} |
public void printf(final String s) { |
ps.printf("%s", s); |
} |
} |
/pluggablejs/trunk/src/net/outlyer/plugins/utils/Hooks.java |
---|
0,0 → 1,14 |
package net.outlyer.plugins.utils; |
import net.outlyer.plugins.sandboxing.SandboxAccessorImpl; |
/** |
* |
*/ |
public class Hooks extends SandboxAccessorImpl { |
// Due to Rhino's magic passing a JS function() is enough |
public void atexit(Runnable callback) { |
getSandbox().addEndHook(callback); |
} |
} |
/pluggablejs/trunk/src/net/outlyer/plugins/utils/package-info.java |
---|
0,0 → 1,10 |
/** |
* This package provides some common functionality that might often be |
* wanted to be exported as global objects. |
* {@see net.outlyer.plugins.sandboxing.PluginEnvironment#exportGlobalObject}. |
*/ |
package net.outlyer.plugins.utils; |