final RubyString strDup(Ruby runtime, RubyClass clazz) { shareLevel = SHARE_LEVEL_BYTELIST; RubyString dup = new RubyString(runtime, clazz, value); dup.shareLevel = SHARE_LEVEL_BYTELIST; dup.flags |= flags & (CR_MASK | TAINTED_F); return dup; }
public static RubyString newEmptyString(Ruby runtime, RubyClass metaClass) { RubyString empty = new RubyString(runtime, metaClass, EMPTY_USASCII_BYTELIST); empty.shareLevel = SHARE_LEVEL_BYTELIST; return empty; }
public static RubyString newAllocatedString(Ruby runtime, RubyClass metaClass) { RubyString empty = new RubyString(runtime, metaClass, EMPTY_ASCII8BIT_BYTELIST); empty.shareLevel = SHARE_LEVEL_BYTELIST; return empty; }
final RubyString strDup(Ruby runtime, RubyClass clazz) { shareLevel = SHARE_LEVEL_BYTELIST; RubyString dup = new RubyString(runtime, clazz, value); dup.shareLevel = SHARE_LEVEL_BYTELIST; dup.flags |= flags & (CR_MASK | TAINTED_F); return dup; }
public static RubyString newStringShared(Ruby runtime, RubyClass clazz, ByteList bytes, Encoding encoding) { RubyString str = new RubyString(runtime, clazz, bytes, encoding); str.shareLevel = SHARE_LEVEL_BYTELIST; return str; }
public static RubyString newAllocatedString(Ruby runtime, RubyClass metaClass) { RubyString empty = new RubyString(runtime, metaClass, EMPTY_ASCII8BIT_BYTELIST); empty.shareLevel = SHARE_LEVEL_BYTELIST; return empty; }
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; }
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; }
public static RubyString newEmptyString(Ruby runtime, RubyClass metaClass, Encoding enc) { EmptyByteListHolder holder = getEmptyByteList(enc); RubyString empty = new RubyString(runtime, metaClass, holder.bytes, holder.cr); empty.shareLevel = SHARE_LEVEL_BYTELIST; return empty; }
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); }
/** Create a new String which uses the same Ruby runtime and the same * class like this String. * * This method should be used to satisfy RCR #38. * @deprecated */ @Deprecated public RubyString newString(ByteList s) { return new RubyString(getRuntime(), getMetaClass(), s); }
/** Create a new String which uses the same Ruby runtime and the same * class like this String. * * This method should be used to satisfy RCR #38. * @deprecated */ @Deprecated public RubyString newString(CharSequence s) { return new RubyString(getRuntime(), getType(), s); }
/** Create a new String which uses the same Ruby runtime and the same * class like this String. * * This method should be used to satisfy RCR #38. * @deprecated */ @Deprecated public RubyString newString(ByteList s) { return new RubyString(getRuntime(), getMetaClass(), s); }
/** Create a new String which uses the same Ruby runtime and the same * class like this String. * * This method should be used to satisfy RCR #38. * @deprecated */ @Deprecated public RubyString newString(CharSequence s) { return new RubyString(getRuntime(), getType(), s); }
/** Create a new String which uses the same Ruby runtime and the same * class like this String. * * This method should be used to satisfy RCR #38. * @deprecated */ @Deprecated public RubyString newString(CharSequence s) { return new RubyString(getRuntime(), getType(), s); }
public static RubyString newString(Ruby runtime, byte[] bytes, int start, int length, Encoding encoding) { byte[] copy = new byte[length]; System.arraycopy(bytes, start, copy, 0, length); return new RubyString(runtime, runtime.getString(), new ByteList(copy, encoding, false)); }
public static RubyString newString(Ruby runtime, byte[] bytes, int start, int length) { byte[] copy = new byte[length]; System.arraycopy(bytes, start, copy, 0, length); return new RubyString(runtime, runtime.getString(), new ByteList(copy, false)); }
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; }
public static RubyString newStringShared(Ruby runtime, RubyClass clazz, ByteList bytes, Encoding encoding) { if (bytes.getEncoding() == encoding) return newStringShared(runtime, clazz, bytes); RubyString str = new RubyString(runtime, clazz, bytes.makeShared(bytes.getBegin(), bytes.getRealSize()), encoding); str.shareLevel = SHARE_LEVEL_BUFFER; // since passing an encoding in does bytes.setEncoding(encoding) return str; }
@JRubyMethod(name = {"succ", "next"}) public IRubyObject succ(ThreadContext context) { Ruby runtime = context.runtime; final RubyString str; if (value.getRealSize() > 0) { str = new RubyString(runtime, getMetaClass(), StringSupport.succCommon(runtime, value)); // TODO: rescan code range ? } else { str = newEmptyString(runtime, getType(), value.getEncoding()); } return str.infectBy(this); }