@Override public String toString() { char[] newBuf = charArray(); try { return Unsafe.stringOf(newBuf); } catch (Exception e) { return new String(newBuf); } }
@Override public String toString() { char[] newBuf = charArray(); try { return Unsafe.stringOf(newBuf); } catch (Exception e) { return new String(newBuf); } }
public String with(String replacement) { if (null != pattern) { return pattern.matcher(text).replaceAll(replacement); } else { if (text.length() < keyword.length()) { return text; } int firstId = this.text.indexOf(this.keyword); if (firstId < 0) { return this.text; } char[] text = Unsafe.bufOf(this.text); char[] target = this.keyword.toCharArray(); char[] replace = replacement.toCharArray(); char[] result = this.replacer.replace(text, target, replace, firstId); return (result == text) ? this.text : Unsafe.stringOf(result); } } }
public String with(String replacement) { if (null != pattern) { return pattern.matcher(text).replaceAll(replacement); } else { if (text.length() < keyword.length()) { return text; } int firstId = this.text.indexOf(this.keyword); if (firstId < 0) { return this.text; } char[] text = Unsafe.bufOf(this.text); char[] target = this.keyword.toCharArray(); char[] replace = replacement.toCharArray(); char[] result = this.replacer.replace(text, target, replace, firstId); return (result == text) ? this.text : Unsafe.stringOf(result); } } }
public byte[] getBytesAscII() { int sz = size(); if (sz == 0) { return new byte[0]; } try { char[] chars; if (sz == buf.length && begin == 0) { chars = buf; } else { chars = new char[sz]; System.arraycopy(buf, begin, chars, 0, sz); } return Unsafe.stringOf(chars).getBytes(Charsets.US_ASCII); } catch (Exception e) { return toString().getBytes(Charsets.US_ASCII); } }
public byte[] getBytesAscII() { int sz = size(); if (sz == 0) { return new byte[0]; } try { char[] chars; if (sz == buf.length && begin == 0) { chars = buf; } else { chars = new char[sz]; System.arraycopy(buf, begin, chars, 0, sz); } return Unsafe.stringOf(chars).getBytes(Charsets.US_ASCII); } catch (Exception e) { return toString().getBytes(Charsets.US_ASCII); } }
@Override public byte[] getBytesUTF8() { int sz = size(); if (sz == 0) { return new byte[0]; } try { char[] chars; if (sz == buf.length && begin == 0) { chars = buf; } else { chars = new char[sz]; System.arraycopy(buf, begin, chars, 0, sz); } return Unsafe.stringOf(chars).getBytes(Charsets.UTF_8); } catch (Exception e) { return toString().getBytes(Charsets.UTF_8); } }
@Override public byte[] getBytesUTF8() { int sz = size(); if (sz == 0) { return new byte[0]; } try { char[] chars; if (sz == buf.length && begin == 0) { chars = buf; } else { chars = new char[sz]; System.arraycopy(buf, begin, chars, 0, sz); } return Unsafe.stringOf(chars).getBytes(Charsets.UTF_8); } catch (Exception e) { return toString().getBytes(Charsets.UTF_8); } }
public String in(String text) { if (null != replacementFunction) { E.illegalStateIf(null != pattern, "Replace with function doesnot support regex search"); replacement = replacementFunction.apply(keyword); } if (null != pattern) { return pattern.matcher(text).replaceAll(replacement); } if (text.length() < keyword.length()) { return text; } int firstId = text.indexOf(this.keyword); if (firstId < 0) { return text; } char[] textArray = Unsafe.bufOf(text); char[] target = this.keyword.toCharArray(); char[] replace = replacement.toCharArray(); char[] result = this.replacer.replace(textArray, target, replace, firstId); return (result == textArray) ? text : Unsafe.stringOf(result); } }
public String in(String text) { if (null != replacementFunction) { E.illegalStateIf(null != pattern, "Replace with function doesnot support regex search"); replacement = replacementFunction.apply(keyword); } if (null != pattern) { return pattern.matcher(text).replaceAll(replacement); } if (text.length() < keyword.length()) { return text; } int firstId = text.indexOf(this.keyword); if (firstId < 0) { return text; } char[] textArray = Unsafe.bufOf(text); char[] target = this.keyword.toCharArray(); char[] replace = replacement.toCharArray(); char[] result = this.replacer.replace(textArray, target, replace, firstId); return (result == textArray) ? text : Unsafe.stringOf(result); } }
public FastStr encodeBASE64() { String s; try { s = Unsafe.stringOf(buf); } catch (Exception e) { s = toString(); } return unsafeOf(S.encodeBASE64(s)); }
public FastStr urlEncode() { String s; try { s = Unsafe.stringOf(buf); } catch (Exception e) { s = toString(); } return unsafeOf(S.urlEncode(s)); }
public FastStr decodeBASE64() { String s; try { s = Unsafe.stringOf(buf); } catch (Exception e) { s = toString(); } return unsafeOf(S.decodeBASE64(s)); }
public FastStr urlEncode() { String s; try { s = Unsafe.stringOf(buf); } catch (Exception e) { s = toString(); } return unsafeOf(S.urlEncode(s)); }
public static String unsafeCapFirst(String s) { if (null == s) { return ""; } try { char[] buf = Unsafe.bufOf(s); char[] newBuf = unsafeCapFirst(buf, 0, buf.length); if (newBuf == buf) return s; return Unsafe.stringOf(newBuf); } catch (Exception e) { return capFirst(s); } }
public static String unsafeCapFirst(String s) { if (null == s) { return ""; } try { char[] buf = Unsafe.bufOf(s); char[] newBuf = unsafeCapFirst(buf, 0, buf.length); if (newBuf == buf) return s; return Unsafe.stringOf(newBuf); } catch (Exception e) { return capFirst(s); } }
public FastStr decodeBASE64() { String s; try { s = Unsafe.stringOf(buf); } catch (Exception e) { s = toString(); } return unsafeOf(S.decodeBASE64(s)); }
public FastStr encodeBASE64() { String s; try { s = Unsafe.stringOf(buf); } catch (Exception e) { s = toString(); } return unsafeOf(S.encodeBASE64(s)); }