org.jruby.Ruby.warningsEnabled()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中org.jruby.Ruby.warningsEnabled方法的一些代码示例,展示了Ruby.warningsEnabled的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.warningsEnabled方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:warningsEnabled

Ruby.warningsEnabled介绍

暂无

代码示例

代码示例来源:origin: org.jruby/jruby-complete

public void warnOnce(ID id, String message) {
  if (!runtime.warningsEnabled()) return;
  if (oncelers.contains(id)) return;
  oncelers.add(id);
  warn(id, message);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * Verbose mode warning methods, their contract is that consumer must explicitly check for runtime.isVerbose()
 * before calling them
 */
public void warning(String message) {
  if (!runtime.warningsEnabled()) return;
  warning(ID.MISCELLANEOUS, message);
}

代码示例来源:origin: org.jruby/jruby-complete

/**
 * Prints a warning, unless $VERBOSE is nil.
 */
@Override
public void warn(ID id, String fileName, int lineNumber, String message) {
  if (!runtime.warningsEnabled()) return;
  StringBuilder buffer = new StringBuilder(100);
  buffer.append(fileName).append(':').append(lineNumber + 1).append(": ");
  buffer.append("warning: ").append(message).append('\n');
  RubyString errorString = runtime.newString(buffer.toString());
  writeWarningDyncall(runtime.getCurrentContext(), errorString);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@Deprecated
@Override
public void warn(ID id, String fileName, int lineNumber, String message, Object... data) {
  if (!runtime.warningsEnabled()) return; // TODO make an assert here
  StringBuilder buffer = new StringBuilder(100);
  buffer.append(fileName).append(':').append(lineNumber).append(' ');
  buffer.append("warning: ").append(message).append('\n');
  IRubyObject errorStream = runtime.getGlobalVariables().get("$stderr");
  errorStream.callMethod(runtime.getCurrentContext(), "write", runtime.newString(buffer.toString()));
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * Prints a warning, unless $VERBOSE is nil.
 */
public void warn(ID id, String fileName, int lineNumber, String message) {
  if (!runtime.warningsEnabled()) return;
  StringBuilder buffer = new StringBuilder(100);
  buffer.append(fileName).append(':').append(lineNumber + 1).append(' ');
  buffer.append("warning: ").append(message).append('\n');
  IRubyObject errorStream = runtime.getGlobalVariables().get("$stderr");
  errorStream.callMethod(runtime.getCurrentContext(), "write", runtime.newString(buffer.toString()));
}

代码示例来源:origin: org.jruby/jruby-complete

/**
 * Prints a warning, only in verbose mode.
 */
@Override
public void warning(ID id, String fileName, int lineNumber, String message) {
  if (!runtime.warningsEnabled() || !runtime.isVerbose()) return;
  warn(id, fileName, lineNumber, message);
}

代码示例来源:origin: org.jruby/jruby-complete

@Override
public void warning(ID id, String message) {
  if (!runtime.warningsEnabled() || !runtime.isVerbose()) return;
  writeWarning(runtime, id, message);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/**
 * Prints a warning, only in verbose mode.
 */
@Override
public void warning(ID id, String fileName, int lineNumber, String message) {
  assert isVerbose();
  if (!runtime.warningsEnabled()) return;
  warn(id, fileName, lineNumber, message);
}

代码示例来源:origin: org.jruby/jruby-complete

/**
 * Verbose mode warning methods, their contract is that consumer must explicitly check for runtime.isVerbose()
 * before calling them
 */
public void warning(String message) {
  if (!isVerbose()) return;
  if (!runtime.warningsEnabled()) return;
  warning(ID.MISCELLANEOUS, message);
}

代码示例来源:origin: org.jruby/jruby-core

@Override
public void warning(ID id, String message) {
  if (!runtime.warningsEnabled() || !runtime.isVerbose()) return;
  writeWarning(runtime, id, message);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * Prints a warning, only in verbose mode.
 */
public void warning(ID id, String fileName, int lineNumber, String message) {
  assert isVerbose();
  if (!runtime.warningsEnabled()) return;
  warn(id, fileName, lineNumber, message);
}

代码示例来源:origin: org.jruby/jruby-complete

/**
 * Prints a warning, unless $VERBOSE is nil.
 */
@Override
@Deprecated
public void warn(ID id, ISourcePosition position, String message) {
  if (!runtime.warningsEnabled()) return;
  warn(id, position.getFile(), position.getLine(), message);
}

代码示例来源:origin: org.jruby/jruby-core

/**
 * Prints a warning, unless $VERBOSE is nil.
 */
@Override
@Deprecated
public void warn(ID id, ISourcePosition position, String message) {
  if (!runtime.warningsEnabled()) return;
  warn(id, position.getFile(), position.getLine(), message);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/**
 * Prints a warning, only in verbose mode.
 */
@Override
public void warning(ID id, ISourcePosition position, String message) {
  if (!runtime.warningsEnabled()) return;
  warning(id, position.getFile(), position.getStartLine() + 1, message);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * Prints a warning, unless $VERBOSE is nil.
 */
public void warn(ID id, ISourcePosition position, String message) {
  if (!runtime.warningsEnabled()) return;
  warn(id, position.getFile(), position.getStartLine(), message);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * Prints a warning, only in verbose mode.
 */
public void warning(ID id, ISourcePosition position, String message) {
  if (!runtime.warningsEnabled()) return;
  warning(id, position.getFile(), position.getStartLine(), message);
}

代码示例来源:origin: org.jruby/jruby-complete

@JRubyMethod(name = "exists?", meta = true)
public static IRubyObject exists_p(ThreadContext context, IRubyObject recv, IRubyObject arg) {
  if (context.runtime.warningsEnabled()) {
    context.runtime.getWarnings().warn("Dir.exists? is a deprecated name, use Dir.exist? instead");
  }
  return exist(context, recv, arg);
}

代码示例来源:origin: org.jruby/jruby-core

@JRubyMethod(name = "exists?", meta = true)
public static IRubyObject exists_p(ThreadContext context, IRubyObject recv, IRubyObject arg) {
  if (context.runtime.warningsEnabled()) {
    context.runtime.getWarnings().warn("Dir.exists? is a deprecated name, use Dir.exist? instead");
  }
  return exist(context, recv, arg);
}

代码示例来源:origin: org.jruby/jruby-complete

@JRubyMethod
public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObject arg) {
  Ruby runtime = context.runtime;
  if (!runtime.warningsEnabled()) return context.nil;
  TypeConverter.checkType(context, arg, runtime.getString());
  RubyString str = (RubyString) arg;
  if (!str.getEncoding().isAsciiCompatible()) {
    throw runtime.newEncodingCompatibilityError("ASCII incompatible encoding: " + str.getEncoding());
  }
  writeWarningToError(runtime.getCurrentContext(), str);
  return context.nil;
}

代码示例来源:origin: org.jruby/jruby-core

@JRubyMethod
public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObject arg) {
  Ruby runtime = context.runtime;
  if (!runtime.warningsEnabled()) return context.nil;
  TypeConverter.checkType(context, arg, runtime.getString());
  RubyString str = (RubyString) arg;
  if (!str.getEncoding().isAsciiCompatible()) {
    throw runtime.newEncodingCompatibilityError("ASCII incompatible encoding: " + str.getEncoding());
  }
  writeWarningToError(runtime.getCurrentContext(), str);
  return context.nil;
}

相关文章

微信公众号

最新文章

更多

Ruby类方法