本文整理了Java中org.jruby.Ruby.defineVariable
方法的一些代码示例,展示了Ruby.defineVariable
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.defineVariable
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:defineVariable
[英]Defines a global variable
[中]定义一个全局变量
代码示例来源:origin: org.jruby/jruby-complete
private static void setStdErr(ScriptingContainer container, Writer writer) {
if (writer == null) {
return;
}
Map map = container.getAttributeMap();
if (map.containsKey(AttributeName.ERROR_WRITER)) {
Writer old = (Writer) map.get(AttributeName.ERROR_WRITER);
if (old == writer) {
return;
}
}
map.put(AttributeName.ERROR_WRITER, writer);
Ruby runtime = container.getProvider().getRuntime();
RubyIO io = getRubyIO(runtime, writer);
runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io), GlobalVariable.Scope.GLOBAL);
runtime.getObject().storeConstant("STDERR", io);
runtime.getGlobalVariables().alias("$deferr", "$stderr");
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private static void setErrorWriter(ScriptingContainer container, Writer writer) throws IOException, BadDescriptorException {
if (writer == null) {
return;
}
Map map = container.getAttributeMap();
if (map.containsKey(AttributeName.ERROR_WRITER)) {
Writer old = (Writer) map.get(AttributeName.ERROR_WRITER);
if (old == writer) {
return;
}
}
map.put(AttributeName.ERROR_WRITER, writer);
Ruby runtime = container.getProvider().getRuntime();
RubyIO io = getRubyIO(runtime, writer);
runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io), GlobalVariable.Scope. GLOBAL);
runtime.getObject().storeConstant("STDERR", io);
runtime.getGlobalVariables().alias("$deferr", "$stderr");
}
代码示例来源:origin: org.jruby/jruby-core
private static void setStdErr(ScriptingContainer container, Writer writer) {
if (writer == null) {
return;
}
Map map = container.getAttributeMap();
if (map.containsKey(AttributeName.ERROR_WRITER)) {
Writer old = (Writer) map.get(AttributeName.ERROR_WRITER);
if (old == writer) {
return;
}
}
map.put(AttributeName.ERROR_WRITER, writer);
Ruby runtime = container.getProvider().getRuntime();
RubyIO io = getRubyIO(runtime, writer);
runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io), GlobalVariable.Scope.GLOBAL);
runtime.getObject().storeConstant("STDERR", io);
runtime.getGlobalVariables().alias("$deferr", "$stderr");
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private static void setErrorWriter(ScriptingContainer container, Writer writer) throws IOException, BadDescriptorException {
if (writer == null) {
return;
}
Map map = container.getAttributeMap();
if (map.containsKey(AttributeName.ERROR_WRITER)) {
Writer old = (Writer) map.get(AttributeName.ERROR_WRITER);
if (old == writer) {
return;
}
}
map.put(AttributeName.ERROR_WRITER, writer);
Ruby runtime = container.getProvider().getRuntime();
RubyIO io = getRubyIO(runtime, writer);
runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io), GlobalVariable.Scope. GLOBAL);
runtime.getObject().storeConstant("STDERR", io);
runtime.getGlobalVariables().alias("$deferr", "$stderr");
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* Replaces a standard input by a specified reader
*
* @param reader is a reader to be set
*/
public void setReader(Reader reader) {
if (reader == null) {
return;
}
Map map = getAttributeMap();
if (map.containsKey(AttributeName.READER)) {
Reader old = (Reader) map.get(AttributeName.READER);
if (old == reader) {
return;
}
}
map.put(AttributeName.READER, reader);
InputStream istream = new ReaderInputStream(reader);
Ruby runtime = provider.getRuntime();
RubyIO io = new RubyIO(runtime, istream);
io.getOpenFile().setSync(true);
runtime.defineVariable(new InputGlobalVariable(runtime, "$stdin", io), GlobalVariable.Scope.GLOBAL);
runtime.getObject().storeConstant("STDIN", io);
}
代码示例来源:origin: org.jruby/jruby-core
/**
* Replaces a standard input by a specified reader
*
* @param reader is a reader to be set
*/
public void setReader(Reader reader) {
if (reader == null) {
return;
}
Map map = getAttributeMap();
if (map.containsKey(AttributeName.READER)) {
Reader old = (Reader) map.get(AttributeName.READER);
if (old == reader) {
return;
}
}
map.put(AttributeName.READER, reader);
InputStream istream = new ReaderInputStream(reader);
Ruby runtime = provider.getRuntime();
RubyIO io = new RubyIO(runtime, istream);
io.getOpenFile().setSync(true);
runtime.defineVariable(new InputGlobalVariable(runtime, "$stdin", io), GlobalVariable.Scope.GLOBAL);
runtime.getObject().storeConstant("STDIN", io);
}
代码示例来源:origin: org.jruby/jruby-core
private static void setStdOut(ScriptingContainer container, Writer writer) {
if (writer == null) {
return;
}
Map map = container.getAttributeMap();
if (map.containsKey(AttributeName.WRITER)) {
Writer old = (Writer) map.get(AttributeName.WRITER);
if (old == writer) {
return;
}
}
map.put(AttributeName.WRITER, writer);
Ruby runtime = container.getProvider().getRuntime();
RubyIO io = getRubyIO(runtime, writer);
runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io), GlobalVariable.Scope.GLOBAL);
runtime.getObject().storeConstant("STDOUT", io);
runtime.getGlobalVariables().alias("$>", "$stdout");
runtime.getGlobalVariables().alias("$defout", "$stdout");
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/**
* Replaces a standard input by a specified reader
*
* @param reader is a reader to be set
*/
public void setReader(Reader reader) {
if (reader == null) {
return;
}
Map map = getAttributeMap();
if (map.containsKey(AttributeName.READER)) {
Reader old = (Reader) map.get(AttributeName.READER);
if (old == reader) {
return;
}
}
map.put(AttributeName.READER, reader);
InputStream istream = new ReaderInputStream(reader);
Ruby runtime = provider.getRuntime();
RubyIO io = new RubyIO(runtime, istream);
io.getOpenFile().getMainStream().setSync(true);
runtime.defineVariable(new InputGlobalVariable(runtime, "$stdin", io), GlobalVariable.Scope.GLOBAL);
runtime.getObject().storeConstant("STDIN", io);
}
代码示例来源:origin: org.jruby/jruby-complete
private static void setStdOut(ScriptingContainer container, Writer writer) {
if (writer == null) {
return;
}
Map map = container.getAttributeMap();
if (map.containsKey(AttributeName.WRITER)) {
Writer old = (Writer) map.get(AttributeName.WRITER);
if (old == writer) {
return;
}
}
map.put(AttributeName.WRITER, writer);
Ruby runtime = container.getProvider().getRuntime();
RubyIO io = getRubyIO(runtime, writer);
runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io), GlobalVariable.Scope.GLOBAL);
runtime.getObject().storeConstant("STDOUT", io);
runtime.getGlobalVariables().alias("$>", "$stdout");
runtime.getGlobalVariables().alias("$defout", "$stdout");
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/**
* Replaces a standard input by a specified reader
*
* @param reader is a reader to be set
*/
public void setReader(Reader reader) {
if (reader == null) {
return;
}
Map map = getAttributeMap();
if (map.containsKey(AttributeName.READER)) {
Reader old = (Reader) map.get(AttributeName.READER);
if (old == reader) {
return;
}
}
map.put(AttributeName.READER, reader);
InputStream istream = new ReaderInputStream(reader);
Ruby runtime = provider.getRuntime();
RubyIO io = new RubyIO(runtime, istream);
io.getOpenFile().getMainStream().setSync(true);
runtime.defineVariable(new InputGlobalVariable(runtime, "$stdin", io), GlobalVariable.Scope.GLOBAL);
runtime.getObject().storeConstant("STDIN", io);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private static void setWriter(ScriptingContainer container, Writer writer) throws IOException, BadDescriptorException {
if (writer == null) {
return;
}
Map map = container.getAttributeMap();
if (map.containsKey(AttributeName.WRITER)) {
Writer old = (Writer) map.get(AttributeName.WRITER);
if (old == writer) {
return;
}
}
map.put(AttributeName.WRITER, writer);
Ruby runtime = container.getProvider().getRuntime();
RubyIO io = getRubyIO(runtime, writer);
runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io), GlobalVariable.Scope.GLOBAL);
runtime.getObject().storeConstant("STDOUT", io);
runtime.getGlobalVariables().alias("$>", "$stdout");
runtime.getGlobalVariables().alias("$defout", "$stdout");
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private static void setWriter(ScriptingContainer container, Writer writer) throws IOException, BadDescriptorException {
if (writer == null) {
return;
}
Map map = container.getAttributeMap();
if (map.containsKey(AttributeName.WRITER)) {
Writer old = (Writer) map.get(AttributeName.WRITER);
if (old == writer) {
return;
}
}
map.put(AttributeName.WRITER, writer);
Ruby runtime = container.getProvider().getRuntime();
RubyIO io = getRubyIO(runtime, writer);
runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io), GlobalVariable.Scope.GLOBAL);
runtime.getObject().storeConstant("STDOUT", io);
runtime.getGlobalVariables().alias("$>", "$stdout");
runtime.getGlobalVariables().alias("$defout", "$stdout");
}
代码示例来源:origin: org.jruby/jruby-core
private void setErrorStream(PrintStream error) {
if (error == null) {
return;
}
Ruby runtime = provider.getRuntime();
RubyIO io = new RubyIO(runtime, error);
io.getOpenFile().setSync(true);
runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io), GlobalVariable.Scope.GLOBAL);
runtime.getObject().storeConstant("STDERR", io);
runtime.getGlobalVariables().alias("$deferr", "$stderr");
}
代码示例来源:origin: org.jruby/jruby-complete
private void setErrorStream(PrintStream error) {
if (error == null) {
return;
}
Ruby runtime = provider.getRuntime();
RubyIO io = new RubyIO(runtime, error);
io.getOpenFile().setSync(true);
runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io), GlobalVariable.Scope.GLOBAL);
runtime.getObject().storeConstant("STDERR", io);
runtime.getGlobalVariables().alias("$deferr", "$stderr");
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private void setErrorStream(PrintStream error) {
if (error == null) {
return;
}
Ruby runtime = provider.getRuntime();
RubyIO io = new RubyIO(runtime, error);
io.getOpenFile().getMainStream().setSync(true);
runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io), GlobalVariable.Scope.GLOBAL);
runtime.getObject().storeConstant("STDERR", io);
runtime.getGlobalVariables().alias("$deferr", "$stderr");
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private void setErrorStream(PrintStream error) {
if (error == null) {
return;
}
Ruby runtime = provider.getRuntime();
RubyIO io = new RubyIO(runtime, error);
io.getOpenFile().getMainStream().setSync(true);
runtime.defineVariable(new OutputGlobalVariable(runtime, "$stderr", io), GlobalVariable.Scope.GLOBAL);
runtime.getObject().storeConstant("STDERR", io);
runtime.getGlobalVariables().alias("$deferr", "$stderr");
}
代码示例来源:origin: org.jruby/jruby-complete
private void setOutputStream(PrintStream pstream) {
if (pstream == null) {
return;
}
Ruby runtime = provider.getRuntime();
RubyIO io = new RubyIO(runtime, pstream);
io.getOpenFile().setSync(true);
runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io), GlobalVariable.Scope.GLOBAL);
runtime.getObject().storeConstant("STDOUT", io);
runtime.getGlobalVariables().alias("$>", "$stdout");
runtime.getGlobalVariables().alias("$defout", "$stdout");
}
代码示例来源:origin: org.jruby/jruby-core
private void setOutputStream(PrintStream pstream) {
if (pstream == null) {
return;
}
Ruby runtime = provider.getRuntime();
RubyIO io = new RubyIO(runtime, pstream);
io.getOpenFile().setSync(true);
runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io), GlobalVariable.Scope.GLOBAL);
runtime.getObject().storeConstant("STDOUT", io);
runtime.getGlobalVariables().alias("$>", "$stdout");
runtime.getGlobalVariables().alias("$defout", "$stdout");
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private void setOutputStream(PrintStream pstream) {
if (pstream == null) {
return;
}
Ruby runtime = provider.getRuntime();
RubyIO io = new RubyIO(runtime, pstream);
io.getOpenFile().getMainStream().setSync(true);
runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io), GlobalVariable.Scope.GLOBAL);
runtime.getObject().storeConstant("STDOUT", io);
runtime.getGlobalVariables().alias("$>", "$stdout");
runtime.getGlobalVariables().alias("$defout", "$stdout");
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private void setOutputStream(PrintStream pstream) {
if (pstream == null) {
return;
}
Ruby runtime = provider.getRuntime();
RubyIO io = new RubyIO(runtime, pstream);
io.getOpenFile().getMainStream().setSync(true);
runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io), GlobalVariable.Scope.GLOBAL);
runtime.getObject().storeConstant("STDOUT", io);
runtime.getGlobalVariables().alias("$>", "$stdout");
runtime.getGlobalVariables().alias("$defout", "$stdout");
}
内容来源于网络,如有侵权,请联系作者删除!