本文整理了Java中org.jruby.Ruby.getString
方法的一些代码示例,展示了Ruby.getString
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.getString
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:getString
暂无
代码示例来源:origin: org.jruby/jruby-complete
private static RubyString concatStrings(final Ruby runtime, String s1, CharSequence s2, String s3, Encoding enc) {
StringBuilder str =
new StringBuilder(s1.length() + s2.length() + s3.length()).append(s1).append(s2).append(s3);
return new RubyString(runtime, runtime.getString(), str, enc);
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyString newStringShared(Ruby runtime, RubyString orig) {
orig.shareLevel = SHARE_LEVEL_BYTELIST;
RubyString str = new RubyString(runtime, runtime.getString(), orig.value);
str.shareLevel = SHARE_LEVEL_BYTELIST;
return str;
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyString newStringShared(Ruby runtime, ByteList bytes, int codeRange) {
RubyString str = new RubyString(runtime, runtime.getString(), bytes, codeRange);
str.shareLevel = SHARE_LEVEL_BYTELIST;
return str;
}
代码示例来源:origin: org.jruby/jruby-complete
private static RubyString newStringShared(Ruby runtime, ByteList bytes, Encoding encoding, int cr) {
RubyString str = newStringShared(runtime, runtime.getString(), bytes, encoding);
str.flags |= cr;
return str;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public final RubyString makeSharedString(Ruby runtime, int index, int len) {
return runtime.is1_9()
? makeShared19(runtime, runtime.getString(), index, len)
: makeShared(runtime, runtime.getString(), index, len);
}
代码示例来源:origin: org.jruby/jruby-complete
public static RubyString newStringShared(Ruby runtime, byte[] bytes, int start, int length, Encoding encoding) {
ByteList byteList = new ByteList(bytes, start, length, encoding, false);
RubyString str = new RubyString(runtime, runtime.getString(), byteList);
str.shareLevel = SHARE_LEVEL_BUFFER;
return str;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/**
* Tries to convert this object to a Ruby String using the
* "to_str" method.
*/
public RubyString convertToString() {
return (RubyString) TypeConverter.convertToType(this, getRuntime().getString(), "to_str");
}
代码示例来源:origin: org.jruby/jruby-core
@JRubyMethod(name = "String", required = 1, module = true, visibility = PRIVATE)
public static IRubyObject new_string(ThreadContext context, IRubyObject recv, IRubyObject object) {
Ruby runtime = context.runtime;
KernelSites sites = sites(context);
IRubyObject tmp = TypeConverter.checkStringType(context, sites.to_str_checked, object, runtime.getString());
if (tmp == context.nil) {
tmp = TypeConverter.convertToType(context, object, runtime.getString(), sites(context).to_s_checked);
}
return tmp;
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(name = {"to_s", "to_str"})
@Override
public IRubyObject to_s() {
Ruby runtime = getRuntime();
if (getMetaClass().getRealClass() != runtime.getString()) {
return strDup(runtime, runtime.getString());
}
return this;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = {"to_s", "to_str"})
@Override
public IRubyObject to_s() {
Ruby runtime = getRuntime();
if (getMetaClass().getRealClass() != runtime.getString()) {
return strDup(runtime, runtime.getString());
}
return this;
}
代码示例来源:origin: org.jruby/jruby-complete
DefaultComparator(ThreadContext context, final boolean honorOverride) {
this.context = context;
if ( honorOverride && context != null ) {
this.fixnumBypass = !honorOverride || context.runtime.getFixnum().isMethodBuiltin("<=>");
this.stringBypass = !honorOverride || context.runtime.getString().isMethodBuiltin("<=>");
}
else { // no-opt
this.fixnumBypass = false;
this.stringBypass = false;
}
}
代码示例来源:origin: org.jruby/jruby-complete
private static RubyString doJoin(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
final Ruby runtime = context.runtime;
final String separator = runtime.getFile().getConstant("SEPARATOR").toString();
final RubyArray argsAry = RubyArray.newArrayMayCopy(runtime, args);
final StringBuilder buffer = new StringBuilder(24);
boolean isTainted = joinImpl(buffer, separator, context, recv, argsAry);
RubyString fixedStr = new RubyString(runtime, runtime.getString(), buffer);
fixedStr.setTaint(isTainted);
return fixedStr;
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod
public static RubyFixnum unseeded_hash(ThreadContext context, IRubyObject recv) {
final Ruby runtime = context.runtime;
if (!(recv instanceof RubyString)) {
throw runtime.newTypeError(recv, runtime.getString());
}
return runtime.newFixnum(((RubyString) recv).unseededStrHashCode(runtime));
}
代码示例来源:origin: org.jruby/jruby-complete
/**
* Tries to convert this object to a Ruby String using the "to_str" method.
* @return a string representation of this
*/
@Override
public RubyString convertToString() {
Ruby runtime = getRuntime();
ThreadContext context = runtime.getCurrentContext();
BasicObjectSites sites = sites(context);
return (RubyString) TypeConverter.convertToType(context, this, runtime.getString(), sites.to_str_checked);
}
代码示例来源:origin: org.jruby/jruby-complete
private static void printExceptionSummary(Ruby runtime, RubyException rEx) {
RubyStackTraceElement[] elements = rEx.getBacktraceElements();
RubyStackTraceElement firstElement = elements.length > 0 ? elements[0] :
new RubyStackTraceElement("", "", "(empty)", 0, false);
String msg = String.format("Exception `%s' at %s:%s - %s\n",
rEx.getMetaClass(),
firstElement.getFileName(), firstElement.getLineNumber(),
TypeConverter.convertToType(rEx, runtime.getString(), "to_s"));
runtime.getErrorStream().print(msg);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod
public static IRubyObject unseeded_hash(ThreadContext context, IRubyObject recv) {
Ruby runtime = context.runtime;
if (!(recv instanceof RubyString)) {
throw runtime.newTypeError(recv, runtime.getString());
}
return runtime.newFixnum(((RubyString)recv).unseededStrHashCode(runtime));
}
}
代码示例来源:origin: org.jruby/jruby-complete
public static IRubyObject checkStringType(IRubyObject self) {
IRubyObject str = TypeConverter.convertToTypeWithCheck(self, getRuntime(self).getString(), "to_str");
if(!str.isNil() && !(str instanceof RubyString)) {
str = RubyString.newEmptyString(getRuntime(self));
}
return str;
}
代码示例来源:origin: org.jruby/jruby-complete
@JRubyMethod(module = true, visibility = Visibility.PRIVATE)
public static IRubyObject ruby_string_to_bytes(IRubyObject recv, IRubyObject string) {
Ruby runtime = recv.getRuntime();
if (!(string instanceof RubyString)) {
throw runtime.newTypeError(string, runtime.getString());
}
return JavaUtil.convertJavaToUsableRubyObject(runtime, ((RubyString)string).getBytes());
}
代码示例来源:origin: org.jruby/jruby-complete
/** short circuit for String key comparison
*
*/
@Override
public final boolean eql(IRubyObject other) {
RubyClass metaclass = getMetaClass();
Ruby runtime = metaclass.getClassRuntime();
if (metaclass != runtime.getString() || metaclass != other.getMetaClass()) return super.eql(other);
return eql19(other);
}
代码示例来源: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;
}
内容来源于网络,如有侵权,请联系作者删除!