/** * Is the string this constant represents a valid constant identifier name. */ public boolean validConstantName() { boolean valid = ByteListHelper.eachCodePoint(getBytes(), (int index, int codepoint, Encoding encoding) -> index == 0 && encoding.isUpper(codepoint) || index != 0 && (encoding.isAlnum(codepoint) || !Encoding.isAscii(codepoint) || codepoint == '_')); return valid && getBytes().length() >= 1; }
/** * Is the string this constant represents a valid constant identifier name. */ public boolean validConstantName() { boolean valid = ByteListHelper.eachCodePoint(getBytes(), (int index, int codepoint, Encoding encoding) -> index == 0 && encoding.isUpper(codepoint) || index != 0 && (encoding.isAlnum(codepoint) || !Encoding.isAscii(codepoint) || codepoint == '_')); return valid && getBytes().length() >= 1; }
private IRubyObject multiByteSwapcase(Ruby runtime, Encoding enc, byte[]bytes, int s, int end) { boolean modify = false; while (s < end) { int c = codePoint(runtime, enc, bytes, s, end); if (enc.isUpper(c)) { enc.codeToMbc(toLower(enc, c), bytes, s); modify = true; } else if (enc.isLower(c)) { enc.codeToMbc(toUpper(enc, c), bytes, s); modify = true; } s += codeLength(runtime, enc, c); } return modify ? this : runtime.getNil(); }
private IRubyObject multiByteSwapcase(Ruby runtime, Encoding enc, byte[]bytes, int s, int end) { boolean modify = false; while (s < end) { int c = codePoint(runtime, enc, bytes, s, end); if (enc.isUpper(c)) { enc.codeToMbc(toLower(enc, c), bytes, s); modify = true; } else if (enc.isLower(c)) { enc.codeToMbc(toUpper(enc, c), bytes, s); modify = true; } s += codeLength(runtime, enc, c); } return modify ? this : runtime.getNil(); }
private IRubyObject multiByteDowncase(Ruby runtime, Encoding enc, byte[]bytes, int s, int end) { boolean modify = false; int c; while (s < end) { if (enc.isAsciiCompatible() && Encoding.isAscii(c = bytes[s] & 0xff)) { if (ASCII.isUpper(c)) { bytes[s] = AsciiTables.ToLowerCaseTable[c]; modify = true; } s++; } else { c = codePoint(runtime, enc, bytes, s, end); if (enc.isUpper(c)) { enc.codeToMbc(toLower(enc, c), bytes, s); modify = true; } s += codeLength(runtime, enc, c); } } return modify ? this : runtime.getNil(); }
private IRubyObject multiByteDowncase(Ruby runtime, Encoding enc, byte[]bytes, int s, int end) { boolean modify = false; int c; while (s < end) { if (enc.isAsciiCompatible() && Encoding.isAscii(c = bytes[s] & 0xff)) { if (ASCII.isUpper(c)) { bytes[s] = AsciiTables.ToLowerCaseTable[c]; modify = true; } s++; } else { c = codePoint(runtime, enc, bytes, s, end); if (enc.isUpper(c)) { enc.codeToMbc(toLower(enc, c), bytes, s); modify = true; } s += codeLength(runtime, enc, c); } } return modify ? this : runtime.getNil(); }
@JRubyMethod(name = "capitalize!", compat = RUBY1_9) public IRubyObject capitalize_bang19(ThreadContext context) { Ruby runtime = context.runtime; Encoding enc = checkDummyEncoding(); if (value.getRealSize() == 0) { modifyCheck(); return runtime.getNil(); } modifyAndKeepCodeRange(); int s = value.getBegin(); int end = s + value.getRealSize(); byte[]bytes = value.getUnsafeBytes(); boolean modify = false; int c = codePoint(runtime, enc, bytes, s, end); if (enc.isLower(c)) { enc.codeToMbc(toUpper(enc, c), bytes, s); modify = true; } s += codeLength(runtime, enc, c); while (s < end) { c = codePoint(runtime, enc, bytes, s, end); if (enc.isUpper(c)) { enc.codeToMbc(toLower(enc, c), bytes, s); modify = true; } s += codeLength(runtime, enc, c); } return modify ? this : runtime.getNil(); }
@JRubyMethod(name = "capitalize!", compat = RUBY1_9) public IRubyObject capitalize_bang19(ThreadContext context) { Ruby runtime = context.runtime; Encoding enc = checkDummyEncoding(); if (value.getRealSize() == 0) { modifyCheck(); return runtime.getNil(); } modifyAndKeepCodeRange(); int s = value.getBegin(); int end = s + value.getRealSize(); byte[]bytes = value.getUnsafeBytes(); boolean modify = false; int c = codePoint(runtime, enc, bytes, s, end); if (enc.isLower(c)) { enc.codeToMbc(toUpper(enc, c), bytes, s); modify = true; } s += codeLength(runtime, enc, c); while (s < end) { c = codePoint(runtime, enc, bytes, s, end); if (enc.isUpper(c)) { enc.codeToMbc(toLower(enc, c), bytes, s); modify = true; } s += codeLength(runtime, enc, c); } return modify ? this : runtime.getNil(); }